[llvm] [DWARFVerifier] Allow overlapping ranges for ICF-merged functions (PR #117952)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 2 15:10:55 PST 2024


dwblaikie wrote:

Not sure I follow the discussion about dsyms - this is a generic feature that impacts/appears in MachO as much as it does on ELF, etc.

Propeller-like debug info can be generated with `-fbasic-block-sections=all`.

There's some differences in linker behavior - lld ICF tombstones all other copies of a function/block, resolving only one copy of the references. Whereas the `gold` linker makes all references to the deduplicated code resolve to it.

So here's an example that shows functions with some parts that overlap and some that don't:
```
$ cat test.cpp
void f1() { }
void f2(bool b) {
  if (b)
    f1();
}
void f3(bool b) {
  if (!b)
    f1();
}
int main(int argc, char** argv) {
  f2(argc);
}
[hi on] blaikie at blaikie-cloudtop2:~/dev/scratch$ clang++-tot test.cpp -g -fuse-ld=gold -Wl,-icf=all -fbasic-block-sections=all && llvm-dwarfdump-tot a.out | grep -A6 DW_TAG_subprogram
...
--
0x00000037:   DW_TAG_subprogram
                DW_AT_ranges    (indexed (0x0) rangelist = 0x00000018
                   [0x0000000000000680, 0x000000000000069f)
                   [0x000000000000069f, 0x00000000000006a9)
                   [0x00000000000006a9, 0x00000000000006af))
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("_Z2f2b")
--
0x0000004b:   DW_TAG_subprogram
                DW_AT_ranges    (indexed (0x1) rangelist = 0x00000022
                   [0x00000000000006b0, 0x00000000000006cf)
                   [0x000000000000069f, 0x00000000000006a9)
                   [0x00000000000006a9, 0x00000000000006af))
                DW_AT_frame_base        (DW_OP_reg6 RBP)
                DW_AT_linkage_name      ("_Z2f3b")
--
...
```


https://github.com/llvm/llvm-project/pull/117952


More information about the llvm-commits mailing list