[Patch] [Debug] New label debugging feature
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
This patch introduces a new debugging feature that can be enabled by defining DEBUG_LABEL. When active, comments are inserted before each label in the assembly dumps that indicate their final reference count. This will be a useful feature for developing and debugging features that work on labels, especially if their reference counts appear to be erroneously high, thus blocking some optimisation potential.
Steps to reproduce:
Apply patch and confiirm correct compilation with no change to generated binaries, and no change to assembly dumps when DEBUG_LABEL is not defined.
Additional information:
I first developed this for aarch64 when I noticed that many label reference counts were higher than they should be (most notably when the only jump was removed, but the destination label was still live), but testing on x86_64-win64 also revealed some labels whose reference counts were too high. For example, in system.s when compiled under -O4:
...
testb $1,%dl
je .Lj60
movb (%rcx,%rdx,1),%al
decq %r8
movb %al,(%rdx)
addq $1,%rdx
# References = 3
.Lj60:
testb $2,%dl
...
Other than "je .Lj60", there is no other reference to .Lj60, not even in the metadata, yet its reference count is revealed to be 3. In the same subroutine, label .Lj59 is revealed to have a reference count of 6, but there are only 3 actual references (two conditional jumps and one unconditional jump).
Mantis conversion info:
- Mantis ID: 38980
- OS: Microsoft Windows
- OS Build: 10 Home
- Build: r49493
- Platform: Cross-platform
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 49494 (#464730dc)