[PATCH] D136039: [DebugInfo] Fix potential CU mismatch for attachRangesOrLowHighPC
DianQK via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 19 07:12:49 PDT 2022
DianQK marked an inline comment as done.
DianQK added inline comments.
================
Comment at: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp:1016
LexicalScope *Scope) {
- DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
+ DIE *SPDie = getOrCreateSubprogramDIE(Sub, includeMinimalInlineScopes());
+ DwarfCompileUnit *ContextCU =
----------------
dblaikie wrote:
> Hmm, I'm not following - can you help me understand why this got pulled out of `updateSubprogramScopeDIE`?
I need get `SPDie` to get `ContextCU` before `attachRangesOrLowHighPC`.
The `attachRangesOrLowHighPC` call in `updateSubprogramScopeDIE` and later `createAndAddScopeChildren`.
Maybe I could use the following code:
```
DIE *SPDie = getOrCreateSubprogramDIE(Sub, includeMinimalInlineScopes());
auto *ContextCU = static_cast<DwarfCompileUnit *>(SPDie->getUnit());
DIE &ScopeDIE = ContextCU->updateSubprogramScopeDIE(Sub);
```
I tried. It fails at `cross-cu-inlining-2.ll` (maybe because call `getOrCreateSubprogramDIE` in different CU?).
Dwarf before the change is:
```
0x00000038: DW_TAG_subprogram [5] * (0x0000002b)
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000010 ".text")
DW_AT_high_pc [DW_FORM_data4] (0x00000001)
DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg7 RSP)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000036] = "bar")
DW_AT_decl_file [DW_FORM_data1] ("A.swift")
DW_AT_decl_line [DW_FORM_data1] (21)
DW_AT_external [DW_FORM_flag_present] (true)
```
After:
```
0x00000038: DW_TAG_subprogram [5] (0x0000002b)
DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000036] = "bar")
DW_AT_decl_file [DW_FORM_data1] ("A.swift")
DW_AT_decl_line [DW_FORM_data1] (21)
DW_AT_external [DW_FORM_flag_present] (true)
0x0000003f: DW_TAG_subprogram [6] * (0x0000002b)
DW_AT_low_pc [DW_FORM_addr] (0x0000000000000010 ".text")
DW_AT_high_pc [DW_FORM_data4] (0x00000001)
DW_AT_frame_base [DW_FORM_exprloc] (DW_OP_reg7 RSP)
```
I think it's ok. But the old version is better?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136039/new/
https://reviews.llvm.org/D136039
More information about the llvm-commits
mailing list