Move the complex address expression out of DIVariable and into an extra
authorAdrian Prantl <aprantl@apple.com>
Wed, 1 Oct 2014 18:55:02 +0000 (18:55 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 1 Oct 2014 18:55:02 +0000 (18:55 +0000)
commit02474a32eb85f03306ae19d376ee26cf89db4af5
tree9b12ffbf4a84fe1d585648806762aa7b8451a7d7
parent0ad623bb0d353871a333cc44d524951764c486be
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.

Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.

By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.

The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)

This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.

What this patch doesn't do:

This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.

http://reviews.llvm.org/D4919
rdar://problem/17994491

Thanks to dblaikie and dexonsmith for reviewing this patch!

Note: I accidentally committed a bogus older version of this patch previously.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
257 files changed:
docs/SourceLevelDebugging.rst
include/llvm/CodeGen/MachineInstr.h
include/llvm/CodeGen/MachineInstrBuilder.h
include/llvm/CodeGen/MachineModuleInfo.h
include/llvm/CodeGen/SelectionDAG.h
include/llvm/IR/DIBuilder.h
include/llvm/IR/DebugInfo.h
include/llvm/IR/IntrinsicInst.h
include/llvm/IR/Intrinsics.td
include/llvm/Support/Dwarf.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
lib/CodeGen/AsmPrinter/DebugLocEntry.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.h
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
lib/CodeGen/InlineSpiller.cpp
lib/CodeGen/LiveDebugVariables.cpp
lib/CodeGen/MachineInstr.cpp
lib/CodeGen/RegAllocFast.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
lib/CodeGen/SelectionDAG/InstrEmitter.cpp
lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/IR/AutoUpgrade.cpp
lib/IR/DIBuilder.cpp
lib/IR/DebugInfo.cpp
lib/Support/Dwarf.cpp
lib/Target/AArch64/AArch64InstrInfo.cpp
lib/Target/AArch64/AArch64InstrInfo.h
lib/Target/X86/X86FastISel.cpp
lib/Transforms/Scalar/SROA.cpp
lib/Transforms/Scalar/ScalarReplAggregates.cpp
lib/Transforms/Utils/Local.cpp
test/Analysis/GlobalsModRef/pr12351.ll
test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNull.ll
test/Assembler/functionlocal-metadata.ll
test/CodeGen/AArch64/aarch64-2014-08-11-MachineCombinerCrash.ll
test/CodeGen/AArch64/arm64-2011-03-17-AsmPrinterCrash.ll
test/CodeGen/ARM/2009-10-16-Scope.ll
test/CodeGen/ARM/2010-04-15-ScavengerDebugValue.ll
test/CodeGen/ARM/2010-06-25-Thumb2ITInvalidIterator.ll
test/CodeGen/ARM/2010-08-04-StackVariable.ll
test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
test/CodeGen/ARM/coalesce-dbgvalue.ll
test/CodeGen/ARM/debug-info-arg.ll
test/CodeGen/ARM/debug-info-blocks.ll
test/CodeGen/ARM/debug-info-branch-folding.ll
test/CodeGen/ARM/debug-info-d16-reg.ll
test/CodeGen/ARM/debug-info-qreg.ll
test/CodeGen/ARM/debug-info-s16-reg.ll
test/CodeGen/ARM/debug-info-sreg2.ll
test/CodeGen/Generic/dbg_value.ll
test/CodeGen/Hexagon/hwloop-dbg.ll
test/CodeGen/Inputs/DbgValueOtherTargets.ll
test/CodeGen/PowerPC/dbg.ll
test/CodeGen/PowerPC/pr17168.ll
test/CodeGen/Thumb/2010-07-15-debugOrdering.ll
test/CodeGen/X86/2009-02-12-DebugInfoVLA.ll
test/CodeGen/X86/2009-10-16-Scope.ll
test/CodeGen/X86/2010-01-18-DbgValue.ll
test/CodeGen/X86/2010-02-01-DbgValueCrash.ll
test/CodeGen/X86/2010-05-25-DotDebugLoc.ll
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
test/CodeGen/X86/2010-05-28-Crash.ll
test/CodeGen/X86/2010-06-01-DeadArg-DbgInfo.ll
test/CodeGen/X86/2010-07-06-DbgCrash.ll
test/CodeGen/X86/2010-08-04-StackVariable.ll
test/CodeGen/X86/2010-11-02-DbgParameter.ll
test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll
test/CodeGen/X86/2012-11-30-handlemove-dbg.ll
test/CodeGen/X86/2012-11-30-misched-dbg.ll
test/CodeGen/X86/2012-11-30-regpres-dbg.ll
test/CodeGen/X86/MachineSink-DbgValue.ll
test/CodeGen/X86/StackColoring-dbg.ll
test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll
test/CodeGen/X86/dbg-changes-codegen.ll
test/CodeGen/X86/fpstack-debuginstr-kill.ll
test/CodeGen/X86/stack-protector-dbginfo.ll
test/CodeGen/XCore/dwarf_debug.ll
test/DebugInfo/2009-11-10-CurrentFn.ll
test/DebugInfo/2010-03-12-llc-crash.ll
test/DebugInfo/2010-03-19-DbgDeclare.ll
test/DebugInfo/2010-03-24-MemberFn.ll
test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll
test/DebugInfo/2010-04-06-NestedFnDbgInfo.ll
test/DebugInfo/2010-05-03-DisableFramePtr.ll
test/DebugInfo/2010-05-03-OriginDIE.ll
test/DebugInfo/2010-06-29-InlinedFnLocalVar.ll
test/DebugInfo/2010-10-01-crash.ll
test/DebugInfo/AArch64/struct_by_value.ll
test/DebugInfo/ARM/PR16736.ll
test/DebugInfo/ARM/lowerbdgdeclare_vla.ll
test/DebugInfo/ARM/s-super-register.ll
test/DebugInfo/ARM/selectiondag-deadcode.ll
test/DebugInfo/Mips/delay-slot.ll
test/DebugInfo/PR20038.ll
test/DebugInfo/SystemZ/variable-loc.ll
test/DebugInfo/X86/2010-04-13-PubType.ll
test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll
test/DebugInfo/X86/2011-12-16-BadStructRef.ll
test/DebugInfo/X86/DW_AT_byte_size.ll
test/DebugInfo/X86/DW_AT_linkage_name.ll
test/DebugInfo/X86/DW_AT_location-reference.ll
test/DebugInfo/X86/DW_AT_object_pointer.ll
test/DebugInfo/X86/aligned_stack_var.ll
test/DebugInfo/X86/arguments.ll
test/DebugInfo/X86/array.ll
test/DebugInfo/X86/array2.ll
test/DebugInfo/X86/block-capture.ll
test/DebugInfo/X86/byvalstruct.ll
test/DebugInfo/X86/cu-ranges-odr.ll
test/DebugInfo/X86/cu-ranges.ll
test/DebugInfo/X86/dbg-byval-parameter.ll
test/DebugInfo/X86/dbg-const-int.ll
test/DebugInfo/X86/dbg-const.ll
test/DebugInfo/X86/dbg-declare-arg.ll
test/DebugInfo/X86/dbg-declare.ll
test/DebugInfo/X86/dbg-i128-const.ll
test/DebugInfo/X86/dbg-merge-loc-entry.ll
test/DebugInfo/X86/dbg-prolog-end.ll
test/DebugInfo/X86/dbg-value-const-byref.ll
test/DebugInfo/X86/dbg-value-dag-combine.ll
test/DebugInfo/X86/dbg-value-inlined-parameter.ll
test/DebugInfo/X86/dbg-value-isel.ll
test/DebugInfo/X86/dbg-value-location.ll
test/DebugInfo/X86/dbg-value-range.ll
test/DebugInfo/X86/dbg-value-terminator.ll
test/DebugInfo/X86/dbg_value_direct.ll
test/DebugInfo/X86/debug-info-block-captured-self.ll
test/DebugInfo/X86/debug-info-blocks.ll
test/DebugInfo/X86/debug-info-static-member.ll
test/DebugInfo/X86/debug-loc-asan.ll
test/DebugInfo/X86/debug-loc-offset.ll
test/DebugInfo/X86/debug-ranges-offset.ll
test/DebugInfo/X86/decl-derived-member.ll
test/DebugInfo/X86/dwarf-aranges-no-dwarf-labels.ll
test/DebugInfo/X86/dwarf-public-names.ll
test/DebugInfo/X86/earlydup-crash.ll
test/DebugInfo/X86/elf-names.ll
test/DebugInfo/X86/empty-and-one-elem-array.ll
test/DebugInfo/X86/ending-run.ll
test/DebugInfo/X86/fission-ranges.ll
test/DebugInfo/X86/formal_parameter.ll
test/DebugInfo/X86/generate-odr-hash.ll
test/DebugInfo/X86/gnu-public-names.ll
test/DebugInfo/X86/inline-member-function.ll
test/DebugInfo/X86/inline-seldag-test.ll
test/DebugInfo/X86/instcombine-instrinsics.ll
test/DebugInfo/X86/lexical_block.ll
test/DebugInfo/X86/line-info.ll
test/DebugInfo/X86/linkage-name.ll
test/DebugInfo/X86/misched-dbg-value.ll
test/DebugInfo/X86/multiple-at-const-val.ll
test/DebugInfo/X86/nodebug_with_debug_loc.ll
test/DebugInfo/X86/objc-property-void.ll
test/DebugInfo/X86/op_deref.ll
test/DebugInfo/X86/parameters.ll
test/DebugInfo/X86/pieces-1.ll
test/DebugInfo/X86/pieces-2.ll
test/DebugInfo/X86/pieces-3.ll
test/DebugInfo/X86/pr11300.ll
test/DebugInfo/X86/pr12831.ll
test/DebugInfo/X86/pr19307.ll
test/DebugInfo/X86/recursive_inlining.ll
test/DebugInfo/X86/reference-argument.ll
test/DebugInfo/X86/rvalue-ref.ll
test/DebugInfo/X86/sret.ll
test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
test/DebugInfo/X86/subrange-type.ll
test/DebugInfo/X86/subreg.ll
test/DebugInfo/X86/subregisters.ll
test/DebugInfo/X86/union-template.ll
test/DebugInfo/X86/vla.ll
test/DebugInfo/array.ll
test/DebugInfo/cross-cu-inlining.ll
test/DebugInfo/cross-cu-linkonce-distinct.ll
test/DebugInfo/cross-cu-linkonce.ll
test/DebugInfo/cu-range-hole.ll
test/DebugInfo/cu-ranges.ll
test/DebugInfo/dead-argument-order.ll
test/DebugInfo/debug-info-qualifiers.ll
test/DebugInfo/dwarf-public-names.ll
test/DebugInfo/enum-types.ll
test/DebugInfo/enum.ll
test/DebugInfo/incorrect-variable-debugloc.ll
test/DebugInfo/inheritance.ll
test/DebugInfo/inline-debug-info-multiret.ll
test/DebugInfo/inline-debug-info.ll
test/DebugInfo/inline-scopes.ll
test/DebugInfo/inlined-arguments.ll
test/DebugInfo/inlined-vars.ll
test/DebugInfo/member-order.ll
test/DebugInfo/missing-abstract-variable.ll
test/DebugInfo/namespace.ll
test/DebugInfo/namespace_inline_function_definition.ll
test/DebugInfo/restrict.ll
test/DebugInfo/sugared-constants.ll
test/DebugInfo/tu-composite.ll
test/DebugInfo/two-cus-from-same-file.ll
test/DebugInfo/unconditional-branch.ll
test/DebugInfo/varargs.ll
test/Instrumentation/AddressSanitizer/coverage-dbg.ll
test/Instrumentation/AddressSanitizer/coverage2-dbg.ll
test/Instrumentation/AddressSanitizer/debug_info.ll
test/Instrumentation/MemorySanitizer/store-origin.ll
test/JitListener/test-common-symbols.ll
test/JitListener/test-inline.ll
test/JitListener/test-parameters.ll
test/Linker/2011-08-18-unique-class-type.ll
test/Linker/2011-08-18-unique-class-type2.ll
test/Linker/DbgDeclare.ll
test/Linker/DbgDeclare2.ll
test/Linker/Inputs/type-unique-inheritance-a.ll
test/Linker/Inputs/type-unique-inheritance-b.ll
test/Linker/Inputs/type-unique-simple2-a.ll
test/Linker/Inputs/type-unique-simple2-b.ll
test/Linker/type-unique-odr-a.ll
test/Linker/type-unique-odr-b.ll
test/Linker/type-unique-simple-a.ll
test/Linker/type-unique-simple-b.ll
test/Linker/type-unique-simple2-a.ll
test/Linker/type-unique-simple2-b.ll
test/Linker/type-unique-type-array-a.ll
test/Linker/type-unique-type-array-b.ll
test/Transforms/AddDiscriminators/no-discriminators.ll
test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
test/Transforms/DeadStoreElimination/inst-limits.ll
test/Transforms/GCOVProfiling/linezero.ll
test/Transforms/GlobalOpt/2009-03-05-dbg.ll
test/Transforms/Inline/ignore-debug-info.ll
test/Transforms/InstCombine/debuginfo.ll
test/Transforms/LICM/debug-value.ll
test/Transforms/LoopIdiom/debug-line.ll
test/Transforms/LoopRotate/dbgvalue.ll
test/Transforms/LoopStrengthReduce/pr12018.ll
test/Transforms/LoopVectorize/dbg.value.ll
test/Transforms/LoopVectorize/debugloc.ll
test/Transforms/Mem2Reg/ConvertDebugInfo.ll
test/Transforms/Mem2Reg/ConvertDebugInfo2.ll
test/Transforms/ObjCARC/allocas.ll
test/Transforms/ObjCARC/basic.ll
test/Transforms/ObjCARC/ensure-that-exception-unwind-path-is-visited.ll
test/Transforms/SLPVectorizer/X86/debug_info.ll
test/Transforms/SampleProfile/branch.ll
test/Transforms/ScalarRepl/debuginfo-preserved.ll
test/Transforms/Scalarizer/dbginfo.ll
test/Transforms/SimplifyCFG/branch-fold-dbg.ll
test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
test/Transforms/StripSymbols/2010-06-30-StripDebug.ll
test/Transforms/StripSymbols/strip-dead-debug-info.ll
unittests/Transforms/Utils/Cloning.cpp