[clang] [clang][DebugInfo] Attach DW_AT_const_value to static data-member definitions if available (PR #72730)

Michael Buch via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 22 08:39:20 PST 2023


Michael137 wrote:

> Do we end up with two DIGlobalVariableExpressions?

Just checked. With this patch, MergeGlobals would produce following IR:
```
...
!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression(DW_OP_plus_uconst, 4, DW_OP_constu, 200, DW_OP_stack_value))
!11 = distinct !DIGlobalVariable(name: "b", linkageName: "_ZN12_GLOBAL__N_13Foo1bE", scope: !2, file: !3, line: 8, type: !4, isLocal: true, isDefinition: true, declaration: !9)
...
!14 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression(DW_OP_constu, 200, DW_OP_stack_value))
...
```
I.e., two `DIGlobalVariableExpression`s for the same `DIGlobalVariable`, which AFAICT would confuse `DwarfDebug` at the moment, which expects there to be a 1-to-1 mapping.

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


More information about the cfe-commits mailing list