[PATCH] D26769: [IR] Remove the DIExpression field from DIGlobalVariable.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 14:58:15 PST 2016
aprantl created this revision.
aprantl added reviewers: dexonsmith, dblaikie, pcc.
aprantl added a subscriber: llvm-commits.
aprantl set the repository for this revision to rL LLVM.
This patch implements PR31013 by introducing a DIGlobalVariableExpression that holds a pair of DIGlobalVariable and DIExpression.
Currently, DIGlobalVariables holds a DIExpression. This is not the best way to model this:
1. The DIGlobalVariable should describe the source level variable, not how to get to its location.
2. It makes it unsafe/hard to update the expressions when we call replaceExpression on the DIGLobalVariable.
3. It makes it impossible to represent a global variable that is in more than one location (e.g., a variable with multiple DW_OP_piece-s). We also moved away from attaching the DIExpression to DILocalVariable for the same reasons.
A better representation would be to add a DIGlobalVariableExpression(var: !DIGlobalVariable(...), expr: !DIExpression(...)) that wraps a global variable and an expression. For example, let's say we have a global symbol g that doesn't need an expression — this would still be represented as:
@g = global i32 0, !dbg !0
!0 = DIGlobalVariable(name: "g", ...)
Later, after some transformation, this becomes:
@opt_g = global i32 *, !dbg !1
!0 = distinct !DIGlobalVariable(name: "g", ...) ; Identical to !0 above.
!1 = !DIGlobalVariableExpr(var: !0, expr: !2) ; Not distinct.
!2 = !DIExpression(DW_OP_deref, ...)
This allows transformations to just add new mergeable metadata on top of the existing DIGlobalVariable without blowing up the representation if they aren't needed.
[reply] [-] Comment 1
For more discussion see https://llvm.org/bugs/show_bug.cgi?id=31013.
Repository:
rL LLVM
https://reviews.llvm.org/D26769
Files:
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/IR/DIBuilder.h
include/llvm/IR/DebugInfo.h
include/llvm/IR/DebugInfoMetadata.h
include/llvm/IR/GlobalVariable.h
include/llvm/IR/Metadata.def
lib/Analysis/ModuleDebugInfoPrinter.cpp
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/IR/AsmWriter.cpp
lib/IR/DIBuilder.cpp
lib/IR/DebugInfo.cpp
lib/IR/DebugInfoMetadata.cpp
lib/IR/LLVMContextImpl.h
lib/IR/Metadata.cpp
lib/IR/Verifier.cpp
lib/Transforms/IPO/StripSymbols.cpp
lib/Transforms/Instrumentation/AddressSanitizer.cpp
test/Assembler/diglobalvariable.ll
test/Assembler/diglobalvariableexpression.ll
test/Bitcode/DIGlobalVariableExpr.ll
test/Bitcode/DIGlobalVariableExpr.ll.bc
test/Bitcode/diglobalvariable-3.8.ll
test/Bitcode/diglobalvariable-3.8.ll.bc
test/DebugInfo/X86/multiple-at-const-val.ll
test/DebugInfo/X86/pr12831.ll
test/DebugInfo/X86/split-global.ll
test/DebugInfo/X86/stack-value-dwarf4.ll
test/DebugInfo/X86/unattached-global.ll
test/Transforms/GlobalMerge/debug-info.ll
unittests/IR/MetadataTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26769.78269.patch
Type: text/x-patch
Size: 71955 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161116/6e0286b4/attachment-0001.bin>
More information about the llvm-commits
mailing list