[llvm] [LLVM][DWARF] Make some effort to avoid duplicates in .debug_ranges. (PR #106614)

Kyle Huey via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 13:38:39 PDT 2024


khuey wrote:

> OOh, I'm with you now. I thought you meant repetition within a range list, but I see you mean two range lists with identical entries

Yes, apologies for the lack of clarity.

> Not sure how I feel about special casing "just the last one" - yeah, I get that it's pretty effective/unlikely to miss much, but doesn't feel great/general/robust.

I agree that it's unsatisfying on some level but it is very effective. See below.

> hmm, which way does this happen - on the way down the tree of scopes, or the way up? does that impact how effective the "last scope matches" technique is? perhaps not...

On the way down, though I don't think it matters.

> You mentioned this technique eliminates "99.99% of the duplicates" - is that an actual number, or a rough estimate? Do you have an example where this technique doesn't catch a duplicate?

It is an actual number, although I miscalculated slightly. The correct number is 99.9%. The 2.1M entries I mentioned is for the Stage 1 compiler (rustc built with the last version of Rust). The Stage 2 compiler (rustc built with the Stage 1 compiler) only has 1836763 entries in .debug_ranges. Of those, 1158605 (63%) are unique. Applying this patch reduces the Stage 2 compiler's .debug_ranges to 1159312, of which again 1158605 are unique. So the number of repeated ranges drops from 678158 to 707. So this technique gets roughly 99.9% of the duplicates.

Of those 707 repeated ranges, 106 of them appear to be due to the linker removing dead code (i.e. every offset in them is very close to zero). I have not investigated any of the 601 remaining non-unique but legitimate-looking entries to see why they remain.

Given how effective this patch is I'd be hesitant to do anything more complicated.

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


More information about the llvm-commits mailing list