[llvm] [DWARFVerifier] Allow overlapping ranges for ICF-merged functions (PR #117952)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 11:53:06 PST 2024
================
@@ -622,7 +627,8 @@ unsigned DWARFVerifier::verifyDieRanges(const DWARFDie &Die,
}
// Verify that children don't intersect.
- const auto IntersectingChild = ParentRI.insert(RI);
+ bool AllowDuplicates = Die.getTag() == DW_TAG_subprogram;
----------------
dwblaikie wrote:
Ah, yeah, looks like we don't even try to apply any verification constraints to ranges between CUs *shrug* they should probably have the same constraints, though - that exact overlap of any range is acceptable, but partial overlap is not. But ah well, I'm not pushing for improving that.
Let's look at lexical scope overlap, then...
I think this example demonstrates almost all the overlapping cases (well, doesn't include distinct subprograms overlapping with each other, but otherwise I think it covers things):
```
int f1(bool a, bool b) {
{
int i = 3;
{
int j = 7;
if (a)
return 5;
}
{
int j = 8;
if (b)
return 5;
}
}
return 3;
}
int main() {
}
```
```
clang++-tot test.cpp -g -ffunction-sections -fbasic-block-sections=all -fuse-ld=gold -Wl,--icf=all
```
```
error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x00000000000006a2, 0x00000000000006ae) and [0x00000000000006a2, 0x00000000000006ae)
0x0000000c: DW_TAG_compile_unit [1] *
DW_AT_producer [DW_FORM_strx1] (indexed (00000000) string = "clang version 20.0.0git (git at github.com:llvm/llvm-project.git 8dd9f206b518a97132f3e2489ccc93704e638353)")
DW_AT_language [DW_FORM_data2] (DW_LANG_C_plus_plus_14)
DW_AT_name [DW_FORM_strx1] (indexed (00000001) string = "test.cpp")
DW_AT_str_offsets_base [DW_FORM_sec_offset] (0x00000008)
DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000)
DW_AT_comp_dir [DW_FORM_strx1] (indexed (00000002) string = "/usr/local/google/home/blaikie/dev/scratch")
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x4) rangelist = 0x00000052
[0x0000000000000670, 0x00000000000006a2)
[0x00000000000006a2, 0x00000000000006ae)
[0x00000000000006ae, 0x00000000000006c4)
[0x00000000000006a2, 0x00000000000006ae)
[0x00000000000006c4, 0x00000000000006d0)
[0x00000000000006d0, 0x00000000000006d5)
[0x00000000000006e0, 0x00000000000006e8))
DW_AT_addr_base [DW_FORM_sec_offset] (0x00000008)
DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x00000000000006a2, 0x00000000000006ae) and [0x00000000000006a2, 0x00000000000006ae)
0x0000002b: DW_TAG_subprogram [2] * (0x0000000c)
DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x0) rangelist = 0x00000020
[0x0000000000000670, 0x00000000000006a2)
[0x00000000000006a2, 0x00000000000006ae)
[0x00000000000006ae, 0x00000000000006c4)
[0x00000000000006a2, 0x00000000000006ae)
[0x00000000000006c4, 0x00000000000006d0)
[0x00000000000006d0, 0x00000000000006d5))
DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg6)
DW_AT_linkage_name [DW_FORM_strx1] (indexed (00000003) string = "_Z2f1bb")
DW_AT_name [DW_FORM_strx1] (indexed (00000004) string = "f1")
DW_AT_decl_file [DW_FORM_data1] ("/usr/local/google/home/blaikie/dev/scratch/test.cpp")
DW_AT_decl_line [DW_FORM_data1] (1)
DW_AT_type [DW_FORM_ref4] (cu + 0x0087 => {0x00000087} "int")
DW_AT_external [DW_FORM_flag_present] (true)
error: DIE has overlapping ranges in DW_AT_ranges attribute: [0x00000000000006a2, 0x00000000000006ae) and [0x00000000000006a2, 0x00000000000006ae)
0x0000004d: DW_TAG_lexical_block [4] * (0x0000002b)
DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x1) rangelist = 0x00000033
[0x0000000000000685, 0x00000000000006a2)
[0x00000000000006a2, 0x00000000000006ae)
[0x00000000000006ae, 0x00000000000006c4)
[0x00000000000006a2, 0x00000000000006ae))
error: DIEs have overlapping address ranges:
0x00000068: DW_TAG_lexical_block [4] * (0x0000004d)
DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x3) rangelist = 0x0000004b
[0x00000000000006ae, 0x00000000000006c4)
[0x00000000000006a2, 0x00000000000006ae))
0x0000005a: DW_TAG_lexical_block [4] * (0x0000004d)
DW_AT_ranges [DW_FORM_rnglistx] (indexed (0x2) rangelist = 0x00000042
[0x000000000000068c, 0x00000000000006a2)
[0x00000000000006a2, 0x00000000000006ae))
```
https://github.com/llvm/llvm-project/pull/117952
More information about the llvm-commits
mailing list