This patch is POC for correctly capturing scope information for
reduced scope variables.
For more context please refer to llvm-dev discussion:
http://lists.llvm.org/pipermail/llvm-dev/2020-April/140962.html
Intent of this patch is to convey overall design/functionality,
seek feedback and converge.
There was an unfortunate delay between the patch and discussion,
Overall design was also discussed in above link(later).
Impact on debug-info statistics(collected from compiling trunk-clang
before and after this patch):
Before this patch:
llvm-dwarfdump --show-section-sizes bin/clang file: bin/clang ---------------------------------------------------- SECTION SIZE (b) ------------- --------- .debug_info 900357322 (58.29%) .debug_loc 868784 (0.06%) .debug_ranges 33411008 (2.16%) .debug_abbrev 4227906 (0.27%) .debug_line 117115289 (7.58%) .debug_str 182932094 (11.84%) Total Size: 1238912403 (80.21%) Total File Size: 1544622040 ----------------------------------------------------
After this patch:
llvm-dwarfdump --show-section-sizes bin/clang ---------------------------------------------------- file: bin/clang ---------------------------------------------------- SECTION SIZE (b) ------------- --------- .debug_info 902111430 (57.62%) .debug_loc 19768599 (1.26%) .debug_ranges 33412752 (2.13%) .debug_abbrev 4305427 (0.28%) .debug_line 117266710 (7.49%) .debug_str 182933982 (11.69%) Total Size: 1259798900 (80.47%) Total File Size: 1565509704 ----------------------------------------------------
we can avoid creating .debug_loc list by introducing new DbgEntity, e.g. called DbgScopedVariable which is handled in a special way (by always creating a single location for it)? Or to set isSafeForSingleLocation (from DwarfDebug::buildLocationList) to true if ScopeBeginSym != nullptr?