[PATCH] D97311: [DebugInfo] Introduce DIConstant metadata for representing named constants
Sourabh Singh Tomar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 08:04:12 PST 2021
SouraVX added a comment.
In D97311#2588856 <https://reviews.llvm.org/D97311#2588856>, @aprantl wrote:
> Have you considered instead introducing a `bool isConstant` field in DILocalVariable? This way we could reuse all the machinery for local/global variables and only need to switch out the TAG in AsmPrinter.
Thanks for the review, @aprantl!
I considered this approach while hacking/iterating, but as mentioned here:
https://lists.llvm.org/pipermail/llvm-dev/2021-February/148447.html
A naïve attempt to represent it as GlobalVariable(or constant) as
!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression(DW_OP_consts, 200))
!8 = distinct !DIGlobalVariable(name: "bar", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true)
This will materialize in DWARF as:
0x0000004a: DW_TAG_variable
DW_AT_name ("bar")
...
DW_AT_location (DW_OP_addr 0x2007d4, DW_OP_consts +200) // This is incorrect, pointing to data section
For `DW_OP_consts` case, it was creating an `location` entry like `GlobalVariable`, this wasn't making sense to me(at least), hence I thought of going this route.
Another motivating reason was: (well not an issue rather) introducing `isConstant` field is a bit non-trivial, considering tightly coupled nature of `DILocalVariable` and `DIGlobalVariable` with `DIVariable`. In my first attempt I introduced this `isConstant` field in `DIVariable` so that it can be utilized well for both situation. Obviously it worked - but broke some round tripping test cases.
I'll give it one more shot, if you have any ideas/suggestion WRT approach, please share I'll be happy to reason/iterate/implement.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97311/new/
https://reviews.llvm.org/D97311
More information about the llvm-commits
mailing list