[llvm] r218787 - Move the complex address expression out of DIVariable and into an extra
Manuel Klimek
klimek at google.com
Thu Oct 2 05:49:18 PDT 2014
This apparently leads to clang segfaults in our internal builds...
On Wed Oct 01 2014 at 9:11:14 PM Adrian Prantl <aprantl at apple.com> wrote:
> Author: adrian
> Date: Wed Oct 1 13:55:02 2014
> New Revision: 218787
>
> URL: http://llvm.org/viewvc/llvm-project?rev=218787&view=rev
> Log:
> 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.
>
> Modified:
> llvm/trunk/docs/SourceLevelDebugging.rst
> llvm/trunk/include/llvm/CodeGen/MachineInstr.h
> llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
> llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
> llvm/trunk/include/llvm/IR/DIBuilder.h
> llvm/trunk/include/llvm/IR/DebugInfo.h
> llvm/trunk/include/llvm/IR/IntrinsicInst.h
> llvm/trunk/include/llvm/IR/Intrinsics.td
> llvm/trunk/include/llvm/Support/Dwarf.h
> llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> llvm/trunk/lib/CodeGen/InlineSpiller.cpp
> llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
> llvm/trunk/lib/CodeGen/MachineInstr.cpp
> llvm/trunk/lib/CodeGen/RegAllocFast.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
> llvm/trunk/lib/IR/AutoUpgrade.cpp
> llvm/trunk/lib/IR/DIBuilder.cpp
> llvm/trunk/lib/IR/DebugInfo.cpp
> llvm/trunk/lib/Support/Dwarf.cpp
> llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.cpp
> llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.h
> llvm/trunk/lib/Target/X86/X86FastISel.cpp
> llvm/trunk/lib/Transforms/Scalar/SROA.cpp
> llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
> llvm/trunk/lib/Transforms/Utils/Local.cpp
> llvm/trunk/test/Analysis/GlobalsModRef/pr12351.ll
> llvm/trunk/test/Assembler/2010-02-05-FunctionLocalMetadataBecomesNu
> ll.ll
> llvm/trunk/test/Assembler/functionlocal-metadata.ll
> llvm/trunk/test/CodeGen/AArch64/aarch64-2014-08-11-
> MachineCombinerCrash.ll
> llvm/trunk/test/CodeGen/AArch64/arm64-2011-03-17-AsmPrinterCrash.ll
> llvm/trunk/test/CodeGen/ARM/2009-10-16-Scope.ll
> llvm/trunk/test/CodeGen/ARM/2010-04-15-ScavengerDebugValue.ll
> llvm/trunk/test/CodeGen/ARM/2010-06-25-Thumb2ITInvalidIterator.ll
> llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll
> llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
> llvm/trunk/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
> llvm/trunk/test/CodeGen/ARM/coalesce-dbgvalue.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-arg.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-blocks.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-branch-folding.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-d16-reg.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-qreg.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-s16-reg.ll
> llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll
> llvm/trunk/test/CodeGen/Generic/dbg_value.ll
> llvm/trunk/test/CodeGen/Hexagon/hwloop-dbg.ll
> llvm/trunk/test/CodeGen/Inputs/DbgValueOtherTargets.ll
> llvm/trunk/test/CodeGen/PowerPC/dbg.ll
> llvm/trunk/test/CodeGen/PowerPC/pr17168.ll
> llvm/trunk/test/CodeGen/Thumb/2010-07-15-debugOrdering.ll
> llvm/trunk/test/CodeGen/X86/2009-02-12-DebugInfoVLA.ll
> llvm/trunk/test/CodeGen/X86/2009-10-16-Scope.ll
> llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll
> llvm/trunk/test/CodeGen/X86/2010-02-01-DbgValueCrash.ll
> llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll
> llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
> llvm/trunk/test/CodeGen/X86/2010-05-28-Crash.ll
> llvm/trunk/test/CodeGen/X86/2010-06-01-DeadArg-DbgInfo.ll
> llvm/trunk/test/CodeGen/X86/2010-07-06-DbgCrash.ll
> llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll
> llvm/trunk/test/CodeGen/X86/2010-11-02-DbgParameter.ll
> llvm/trunk/test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll
> llvm/trunk/test/CodeGen/X86/2012-11-30-handlemove-dbg.ll
> llvm/trunk/test/CodeGen/X86/2012-11-30-misched-dbg.ll
> llvm/trunk/test/CodeGen/X86/2012-11-30-regpres-dbg.ll
> llvm/trunk/test/CodeGen/X86/MachineSink-DbgValue.ll
> llvm/trunk/test/CodeGen/X86/StackColoring-dbg.ll
> llvm/trunk/test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll
> llvm/trunk/test/CodeGen/X86/dbg-changes-codegen.ll
> llvm/trunk/test/CodeGen/X86/fpstack-debuginstr-kill.ll
> llvm/trunk/test/CodeGen/X86/stack-protector-dbginfo.ll
> llvm/trunk/test/CodeGen/XCore/dwarf_debug.ll
> llvm/trunk/test/DebugInfo/2009-11-10-CurrentFn.ll
> llvm/trunk/test/DebugInfo/2010-03-12-llc-crash.ll
> llvm/trunk/test/DebugInfo/2010-03-19-DbgDeclare.ll
> llvm/trunk/test/DebugInfo/2010-03-24-MemberFn.ll
> llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll
> llvm/trunk/test/DebugInfo/2010-04-06-NestedFnDbgInfo.ll
> llvm/trunk/test/DebugInfo/2010-05-03-DisableFramePtr.ll
> llvm/trunk/test/DebugInfo/2010-05-03-OriginDIE.ll
> llvm/trunk/test/DebugInfo/2010-06-29-InlinedFnLocalVar.ll
> llvm/trunk/test/DebugInfo/2010-10-01-crash.ll
> llvm/trunk/test/DebugInfo/AArch64/struct_by_value.ll
> llvm/trunk/test/DebugInfo/ARM/PR16736.ll
> llvm/trunk/test/DebugInfo/ARM/lowerbdgdeclare_vla.ll
> llvm/trunk/test/DebugInfo/ARM/s-super-register.ll
> llvm/trunk/test/DebugInfo/ARM/selectiondag-deadcode.ll
> llvm/trunk/test/DebugInfo/Mips/delay-slot.ll
> llvm/trunk/test/DebugInfo/PR20038.ll
> llvm/trunk/test/DebugInfo/SystemZ/variable-loc.ll
> llvm/trunk/test/DebugInfo/X86/2010-04-13-PubType.ll
> llvm/trunk/test/DebugInfo/X86/2011-09-26-GlobalVarContext.ll
> llvm/trunk/test/DebugInfo/X86/2011-12-16-BadStructRef.ll
> llvm/trunk/test/DebugInfo/X86/DW_AT_byte_size.ll
> llvm/trunk/test/DebugInfo/X86/DW_AT_linkage_name.ll
> llvm/trunk/test/DebugInfo/X86/DW_AT_location-reference.ll
> llvm/trunk/test/DebugInfo/X86/DW_AT_object_pointer.ll
> llvm/trunk/test/DebugInfo/X86/aligned_stack_var.ll
> llvm/trunk/test/DebugInfo/X86/arguments.ll
> llvm/trunk/test/DebugInfo/X86/array.ll
> llvm/trunk/test/DebugInfo/X86/array2.ll
> llvm/trunk/test/DebugInfo/X86/block-capture.ll
> llvm/trunk/test/DebugInfo/X86/byvalstruct.ll
> llvm/trunk/test/DebugInfo/X86/cu-ranges-odr.ll
> llvm/trunk/test/DebugInfo/X86/cu-ranges.ll
> llvm/trunk/test/DebugInfo/X86/dbg-byval-parameter.ll
> llvm/trunk/test/DebugInfo/X86/dbg-const-int.ll
> llvm/trunk/test/DebugInfo/X86/dbg-const.ll
> llvm/trunk/test/DebugInfo/X86/dbg-declare-arg.ll
> llvm/trunk/test/DebugInfo/X86/dbg-declare.ll
> llvm/trunk/test/DebugInfo/X86/dbg-i128-const.ll
> llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll
> llvm/trunk/test/DebugInfo/X86/dbg-prolog-end.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-const-byref.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-dag-combine.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-inlined-parameter.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-isel.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-location.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-range.ll
> llvm/trunk/test/DebugInfo/X86/dbg-value-terminator.ll
> llvm/trunk/test/DebugInfo/X86/dbg_value_direct.ll
> llvm/trunk/test/DebugInfo/X86/debug-info-block-captured-self.ll
> llvm/trunk/test/DebugInfo/X86/debug-info-blocks.ll
> llvm/trunk/test/DebugInfo/X86/debug-info-static-member.ll
> llvm/trunk/test/DebugInfo/X86/debug-loc-asan.ll
> llvm/trunk/test/DebugInfo/X86/debug-loc-offset.ll
> llvm/trunk/test/DebugInfo/X86/debug-ranges-offset.ll
> llvm/trunk/test/DebugInfo/X86/decl-derived-member.ll
> llvm/trunk/test/DebugInfo/X86/dwarf-aranges-no-dwarf-labels.ll
> llvm/trunk/test/DebugInfo/X86/dwarf-public-names.ll
> llvm/trunk/test/DebugInfo/X86/earlydup-crash.ll
> llvm/trunk/test/DebugInfo/X86/elf-names.ll
> llvm/trunk/test/DebugInfo/X86/empty-and-one-elem-array.ll
> llvm/trunk/test/DebugInfo/X86/ending-run.ll
> llvm/trunk/test/DebugInfo/X86/fission-ranges.ll
> llvm/trunk/test/DebugInfo/X86/formal_parameter.ll
> llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll
> llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll
> llvm/trunk/test/DebugInfo/X86/inline-member-function.ll
> llvm/trunk/test/DebugInfo/X86/inline-seldag-test.ll
> llvm/trunk/test/DebugInfo/X86/instcombine-instrinsics.ll
> llvm/trunk/test/DebugInfo/X86/lexical_block.ll
> llvm/trunk/test/DebugInfo/X86/line-info.ll
> llvm/trunk/test/DebugInfo/X86/linkage-name.ll
> llvm/trunk/test/DebugInfo/X86/misched-dbg-value.ll
> llvm/trunk/test/DebugInfo/X86/multiple-at-const-val.ll
> llvm/trunk/test/DebugInfo/X86/nodebug_with_debug_loc.ll
> llvm/trunk/test/DebugInfo/X86/objc-property-void.ll
> llvm/trunk/test/DebugInfo/X86/op_deref.ll
> llvm/trunk/test/DebugInfo/X86/parameters.ll
> llvm/trunk/test/DebugInfo/X86/pieces-1.ll
> llvm/trunk/test/DebugInfo/X86/pieces-2.ll
> llvm/trunk/test/DebugInfo/X86/pieces-3.ll
> llvm/trunk/test/DebugInfo/X86/pr11300.ll
> llvm/trunk/test/DebugInfo/X86/pr12831.ll
> llvm/trunk/test/DebugInfo/X86/pr19307.ll
> llvm/trunk/test/DebugInfo/X86/recursive_inlining.ll
> llvm/trunk/test/DebugInfo/X86/reference-argument.ll
> llvm/trunk/test/DebugInfo/X86/rvalue-ref.ll
> llvm/trunk/test/DebugInfo/X86/sret.ll
> llvm/trunk/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
> llvm/trunk/test/DebugInfo/X86/subrange-type.ll
> llvm/trunk/test/DebugInfo/X86/subreg.ll
> llvm/trunk/test/DebugInfo/X86/subregisters.ll
> llvm/trunk/test/DebugInfo/X86/union-template.ll
> llvm/trunk/test/DebugInfo/X86/vla.ll
> llvm/trunk/test/DebugInfo/array.ll
> llvm/trunk/test/DebugInfo/cross-cu-inlining.ll
> llvm/trunk/test/DebugInfo/cross-cu-linkonce-distinct.ll
> llvm/trunk/test/DebugInfo/cross-cu-linkonce.ll
> llvm/trunk/test/DebugInfo/cu-range-hole.ll
> llvm/trunk/test/DebugInfo/cu-ranges.ll
> llvm/trunk/test/DebugInfo/dead-argument-order.ll
> llvm/trunk/test/DebugInfo/debug-info-qualifiers.ll
> llvm/trunk/test/DebugInfo/dwarf-public-names.ll
> llvm/trunk/test/DebugInfo/enum-types.ll
> llvm/trunk/test/DebugInfo/enum.ll
> llvm/trunk/test/DebugInfo/incorrect-variable-debugloc.ll
> llvm/trunk/test/DebugInfo/inheritance.ll
> llvm/trunk/test/DebugInfo/inline-debug-info-multiret.ll
> llvm/trunk/test/DebugInfo/inline-debug-info.ll
> llvm/trunk/test/DebugInfo/inline-scopes.ll
> llvm/trunk/test/DebugInfo/inlined-arguments.ll
> llvm/trunk/test/DebugInfo/inlined-vars.ll
> llvm/trunk/test/DebugInfo/member-order.ll
> llvm/trunk/test/DebugInfo/missing-abstract-variable.ll
> llvm/trunk/test/DebugInfo/namespace.ll
> llvm/trunk/test/DebugInfo/namespace_inline_function_definition.ll
> llvm/trunk/test/DebugInfo/restrict.ll
> llvm/trunk/test/DebugInfo/sugared-constants.ll
> llvm/trunk/test/DebugInfo/tu-composite.ll
> llvm/trunk/test/DebugInfo/two-cus-from-same-file.ll
> llvm/trunk/test/DebugInfo/unconditional-branch.ll
> llvm/trunk/test/DebugInfo/varargs.ll
> llvm/trunk/test/Instrumentation/AddressSanitizer/coverage-dbg.ll
> llvm/trunk/test/Instrumentation/AddressSanitizer/coverage2-dbg.ll
> llvm/trunk/test/Instrumentation/AddressSanitizer/debug_info.ll
> llvm/trunk/test/Instrumentation/MemorySanitizer/store-origin.ll
> llvm/trunk/test/JitListener/test-common-symbols.ll
> llvm/trunk/test/JitListener/test-inline.ll
> llvm/trunk/test/JitListener/test-parameters.ll
> llvm/trunk/test/Linker/2011-08-18-unique-class-type.ll
> llvm/trunk/test/Linker/2011-08-18-unique-class-type2.ll
> llvm/trunk/test/Linker/DbgDeclare.ll
> llvm/trunk/test/Linker/DbgDeclare2.ll
> llvm/trunk/test/Linker/Inputs/type-unique-inheritance-a.ll
> llvm/trunk/test/Linker/Inputs/type-unique-inheritance-b.ll
> llvm/trunk/test/Linker/Inputs/type-unique-simple2-a.ll
> llvm/trunk/test/Linker/Inputs/type-unique-simple2-b.ll
> llvm/trunk/test/Linker/type-unique-odr-a.ll
> llvm/trunk/test/Linker/type-unique-odr-b.ll
> llvm/trunk/test/Linker/type-unique-simple-a.ll
> llvm/trunk/test/Linker/type-unique-simple-b.ll
> llvm/trunk/test/Linker/type-unique-simple2-a.ll
> llvm/trunk/test/Linker/type-unique-simple2-b.ll
> llvm/trunk/test/Linker/type-unique-type-array-a.ll
> llvm/trunk/test/Linker/type-unique-type-array-b.ll
> llvm/trunk/test/Transforms/AddDiscriminators/no-discriminators.ll
> llvm/trunk/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
> llvm/trunk/test/Transforms/DeadStoreElimination/inst-limits.ll
> llvm/trunk/test/Transforms/GCOVProfiling/linezero.ll
> llvm/trunk/test/Transforms/GlobalOpt/2009-03-05-dbg.ll
> llvm/trunk/test/Transforms/Inline/ignore-debug-info.ll
> llvm/trunk/test/Transforms/InstCombine/debuginfo.ll
> llvm/trunk/test/Transforms/LICM/debug-value.ll
> llvm/trunk/test/Transforms/LoopIdiom/debug-line.ll
> llvm/trunk/test/Transforms/LoopRotate/dbgvalue.ll
> llvm/trunk/test/Transforms/LoopStrengthReduce/pr12018.ll
> llvm/trunk/test/Transforms/LoopVectorize/dbg.value.ll
> llvm/trunk/test/Transforms/LoopVectorize/debugloc.ll
> llvm/trunk/test/Transforms/Mem2Reg/ConvertDebugInfo.ll
> llvm/trunk/test/Transforms/Mem2Reg/ConvertDebugInfo2.ll
> llvm/trunk/test/Transforms/ObjCARC/allocas.ll
> llvm/trunk/test/Transforms/ObjCARC/basic.ll
> llvm/trunk/test/Transforms/ObjCARC/ensure-that-exception-
> unwind-path-is-visited.ll
> llvm/trunk/test/Transforms/SLPVectorizer/X86/debug_info.ll
> llvm/trunk/test/Transforms/SampleProfile/branch.ll
> llvm/trunk/test/Transforms/ScalarRepl/debuginfo-preserved.ll
> llvm/trunk/test/Transforms/Scalarizer/dbginfo.ll
> llvm/trunk/test/Transforms/SimplifyCFG/branch-fold-dbg.ll
> llvm/trunk/test/Transforms/SimplifyCFG/hoist-dbgvalue.ll
> llvm/trunk/test/Transforms/StripSymbols/2010-06-30-StripDebug.ll
> llvm/trunk/test/Transforms/StripSymbols/strip-dead-debug-info.ll
> llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
>
> Modified: llvm/trunk/docs/SourceLevelDebugging.rst
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/
> SourceLevelDebugging.rst?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/docs/SourceLevelDebugging.rst (original)
> +++ llvm/trunk/docs/SourceLevelDebugging.rst Wed Oct 1 13:55:02 2014
> @@ -571,7 +571,7 @@ Local variables
> metadata, ;; Reference to the type descriptor
> i32, ;; flags
> metadata ;; (optional) Reference to inline location
> - metadata ;; (optional) Reference to a complex expression (see below)
> + metadata ;; (optional) Reference to a complex expression.
> }
>
> These descriptors are used to define variables local to a sub program.
> The
> @@ -590,7 +590,20 @@ The context is either the subprogram or
> Name the source variable name. Context and line indicate where the
> variable
> was defined. Type descriptor defines the declared type of the variable.
>
> -The ``OpPiece`` operator is used for (typically larger aggregate)
> +Complex Expressions
> +^^^^^^^^^^^^^^^^^^^
> +.. code-block:: llvm
> +
> + !8 = metadata !{
> + i32, ;; DW_TAG_expression
> + ...
> + }
> +
> +Complex expressions describe variable storage locations in terms of
> +prefix-notated DWARF expressions. Currently the only supported
> +operators are ``DW_OP_plus``, ``DW_OP_deref``, and ``DW_OP_piece``.
> +
> +The ``DW_OP_piece`` operator is used for (typically larger aggregate)
> variables that are fragmented across several locations. It takes two
> i32 arguments, an offset and a size in bytes to describe which piece
> of the variable is at this location.
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/CodeGen/MachineInstr.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Wed Oct 1 13:55:02
> 2014
> @@ -244,12 +244,22 @@ public:
> ///
> DebugLoc getDebugLoc() const { return debugLoc; }
>
> - /// getDebugVariable() - Return the debug variable referenced by
> + /// \brief Return the debug variable referenced by
> /// this DBG_VALUE instruction.
> DIVariable getDebugVariable() const {
> assert(isDebugValue() && "not a DBG_VALUE");
> - const MDNode *Var = getOperand(getNumOperands() - 1).getMetadata();
> - return DIVariable(Var);
> + DIVariable Var(getOperand(2).getMetadata());
> + assert(Var.Verify() && "not a DIVariable");
> + return Var;
> + }
> +
> + /// \brief Return the complex address expression referenced by
> + /// this DBG_VALUE instruction.
> + DIExpression getDebugExpression() const {
> + assert(isDebugValue() && "not a DBG_VALUE");
> + DIExpression Expr(getOperand(3).getMetadata());
> + assert(Expr.Verify() && "not a DIExpression");
> + return Expr;
> }
>
> /// emitError - Emit an error referring to the source location of this
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/
> MachineInstrBuilder.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Wed Oct 1
> 13:55:02 2014
> @@ -170,6 +170,8 @@ public:
>
> const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
> MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
> + assert((MI->isDebugValue() ? MI->getDebugVariable().Verify() : true)
> &&
> + "first MDNode argument of a DBG_VALUE not a DIVariable");
> return *this;
> }
>
> @@ -345,24 +347,25 @@ inline MachineInstrBuilder BuildMI(Machi
> /// address. The convention is that a DBG_VALUE is indirect iff the
> /// second operand is an immediate.
> ///
> -inline MachineInstrBuilder BuildMI(MachineFunction &MF,
> - DebugLoc DL,
> - const MCInstrDesc &MCID,
> - bool IsIndirect,
> - unsigned Reg,
> - unsigned Offset,
> - const MDNode *MD) {
> +inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
> + const MCInstrDesc &MCID, bool
> IsIndirect,
> + unsigned Reg, unsigned Offset,
> + const MDNode *Variable, const MDNode
> *Expr) {
> + assert(DIVariable(Variable).Verify() && "not a DIVariable");
> + assert(DIExpression(Expr).Verify() && "not a DIExpression");
> if (IsIndirect)
> return BuildMI(MF, DL, MCID)
> - .addReg(Reg, RegState::Debug)
> - .addImm(Offset)
> - .addMetadata(MD);
> + .addReg(Reg, RegState::Debug)
> + .addImm(Offset)
> + .addMetadata(Variable)
> + .addMetadata(Expr);
> else {
> assert(Offset == 0 && "A direct address cannot have an offset.");
> return BuildMI(MF, DL, MCID)
> - .addReg(Reg, RegState::Debug)
> - .addReg(0U, RegState::Debug)
> - .addMetadata(MD);
> + .addReg(Reg, RegState::Debug)
> + .addReg(0U, RegState::Debug)
> + .addMetadata(Variable)
> + .addMetadata(Expr);
> }
> }
>
> @@ -371,15 +374,15 @@ inline MachineInstrBuilder BuildMI(Machi
> /// address and inserts it at position I.
> ///
> inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
> - MachineBasicBlock::iterator I,
> - DebugLoc DL,
> - const MCInstrDesc &MCID,
> - bool IsIndirect,
> - unsigned Reg,
> - unsigned Offset,
> - const MDNode *MD) {
> + MachineBasicBlock::iterator I,
> DebugLoc DL,
> + const MCInstrDesc &MCID, bool
> IsIndirect,
> + unsigned Reg, unsigned Offset,
> + const MDNode *Variable, const MDNode
> *Expr) {
> + assert(DIVariable(Variable).Verify() && "not a DIVariable");
> + assert(DIExpression(Expr).Verify() && "not a DIExpression");
> MachineFunction &MF = *BB.getParent();
> - MachineInstr *MI = BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, MD);
> + MachineInstr *MI =
> + BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
> BB.insert(I, MI);
> return MachineInstrBuilder(MF, MI);
> }
>
> Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/
> MachineModuleInfo.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Oct 1
> 13:55:02 2014
> @@ -166,6 +166,7 @@ public:
>
> struct VariableDbgInfo {
> TrackingVH<MDNode> Var;
> + TrackingVH<MDNode> Expr;
> unsigned Slot;
> DebugLoc Loc;
> };
> @@ -390,8 +391,9 @@ public:
>
> /// setVariableDbgInfo - Collect information used to emit debugging
> /// information of a variable.
> - void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc) {
> - VariableDbgInfo Info = { N, Slot, Loc };
> + void setVariableDbgInfo(MDNode *Var, MDNode *Expr, unsigned Slot,
> + DebugLoc Loc) {
> + VariableDbgInfo Info = {Var, Expr, Slot, Loc};
> VariableDbgInfos.push_back(std::move(Info));
> }
>
>
> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/CodeGen/SelectionDAG.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Oct 1 13:55:02
> 2014
> @@ -984,15 +984,18 @@ public:
>
> /// getDbgValue - Creates a SDDbgValue node.
> ///
> - SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R,
> - bool IsIndirect, uint64_t Off,
> - DebugLoc DL, unsigned O);
> - /// Constant.
> - SDDbgValue *getConstantDbgValue(MDNode *MDPtr, const Value *C, uint64_t
> Off,
> - DebugLoc DL, unsigned O);
> - /// Frame index.
> - SDDbgValue *getFrameIndexDbgValue(MDNode *MDPtr, unsigned FI, uint64_t
> Off,
> - DebugLoc DL, unsigned O);
> + /// SDNode
> + SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned
> R,
> + bool IsIndirect, uint64_t Off, DebugLoc DL,
> + unsigned O);
> +
> + /// Constant
> + SDDbgValue *getConstantDbgValue(MDNode *Var, MDNode *Expr, const Value
> *C,
> + uint64_t Off, DebugLoc DL, unsigned O);
> +
> + /// FrameIndex
> + SDDbgValue *getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, unsigned
> FI,
> + uint64_t Off, DebugLoc DL, unsigned
> O);
>
> /// RemoveDeadNode - Remove the specified node from the system. If any
> of its
> /// operands then becomes dead, remove them as well. Inform
> UpdateListener
>
> Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/IR/DIBuilder.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
> +++ llvm/trunk/include/llvm/IR/DIBuilder.h Wed Oct 1 13:55:02 2014
> @@ -85,7 +85,6 @@ namespace llvm {
>
> public:
> explicit DIBuilder(Module &M);
> - enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
> enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
>
> /// finalize - Construct any deferred debug info descriptors.
> @@ -501,33 +500,18 @@ namespace llvm {
> unsigned Flags = 0,
> unsigned ArgNo = 0);
>
> -
> - /// createComplexVariable - Create a new descriptor for the specified
> + /// createExpression - Create a new descriptor for the specified
> /// variable which has a complex address expression for its address.
> - /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
> - /// DW_TAG_arg_variable.
> - /// @param Scope Variable scope.
> - /// @param Name Variable name.
> - /// @param F File where this variable is defined.
> - /// @param LineNo Line number.
> - /// @param Ty Variable Type
> /// @param Addr An array of complex address operations.
> - /// @param ArgNo If this variable is an argument then this
> argument's
> - /// number. 1 indicates 1st argument.
> - DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
> - StringRef Name, DIFile F, unsigned
> LineNo,
> - DITypeRef Ty, ArrayRef<Value *> Addr,
> - unsigned ArgNo = 0);
> + DIExpression createExpression(ArrayRef<Value *> Addr = None);
>
> - /// createVariablePiece - Create a descriptor to describe one part
> + /// createPieceExpression - Create a descriptor to describe one part
> /// of aggregate variable that is fragmented across multiple Values.
> ///
> - /// @param Variable Variable that is partially represented by
> this.
> /// @param OffsetInBytes Offset of the piece in bytes.
> /// @param SizeInBytes Size of the piece in bytes.
> - DIVariable createVariablePiece(DIVariable Variable,
> - unsigned OffsetInBytes,
> - unsigned SizeInBytes);
> + DIExpression createPieceExpression(unsigned OffsetInBytes,
> + unsigned SizeInBytes);
>
> /// createFunction - Create a new descriptor for the specified
> subprogram.
> /// See comments in DISubprogram for descriptions of these fields.
> @@ -675,34 +659,37 @@ namespace llvm {
> /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
> /// @param Storage llvm::Value of the variable
> /// @param VarInfo Variable's debug info descriptor.
> + /// @param Expr A complex location expression.
> /// @param InsertAtEnd Location for the new intrinsic.
> Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
> - BasicBlock *InsertAtEnd);
> + DIExpression Expr, BasicBlock
> *InsertAtEnd);
>
> /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
> /// @param Storage llvm::Value of the variable
> /// @param VarInfo Variable's debug info descriptor.
> + /// @param Expr A complex location expression.
> /// @param InsertBefore Location for the new intrinsic.
> Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
> - Instruction *InsertBefore);
> -
> + DIExpression Expr, Instruction
> *InsertBefore);
>
> /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic
> call.
> /// @param Val llvm::Value of the variable
> /// @param Offset Offset
> /// @param VarInfo Variable's debug info descriptor.
> + /// @param Expr A complex location expression.
> /// @param InsertAtEnd Location for the new intrinsic.
> Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t
> Offset,
> - DIVariable VarInfo,
> + DIVariable VarInfo, DIExpression
> Expr,
> BasicBlock *InsertAtEnd);
>
> /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic
> call.
> /// @param Val llvm::Value of the variable
> /// @param Offset Offset
> /// @param VarInfo Variable's debug info descriptor.
> + /// @param Expr A complex location expression.
> /// @param InsertBefore Location for the new intrinsic.
> Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t
> Offset,
> - DIVariable VarInfo,
> + DIVariable VarInfo, DIExpression
> Expr,
> Instruction *InsertBefore);
> };
> } // end namespace llvm
>
> Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/IR/DebugInfo.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
> +++ llvm/trunk/include/llvm/IR/DebugInfo.h Wed Oct 1 13:55:02 2014
> @@ -150,6 +150,7 @@ public:
> bool isTemplateValueParameter() const;
> bool isObjCProperty() const;
> bool isImportedEntity() const;
> + bool isExpression() const;
>
> /// print - print descriptor.
> void print(raw_ostream &OS) const;
> @@ -720,20 +721,6 @@ public:
> /// Verify - Verify that a variable descriptor is well formed.
> bool Verify() const;
>
> - /// HasComplexAddr - Return true if the variable has a complex address.
> - bool hasComplexAddress() const { return getNumAddrElements() > 0; }
> -
> - /// \brief Return the size of this variable's complex address or
> - /// zero if there is none.
> - unsigned getNumAddrElements() const {
> - if (DbgNode->getNumOperands() < 9)
> - return 0;
> - return getDescriptorField(8)->getNumOperands();
> - }
> -
> - /// \brief return the Idx'th complex address element.
> - uint64_t getAddrElement(unsigned Idx) const;
> -
> /// isBlockByrefVariable - Return true if the variable was declared as
> /// a "__block" variable (Apple Blocks).
> bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
> @@ -744,6 +731,35 @@ public:
> /// information for an inlined function arguments.
> bool isInlinedFnArgument(const Function *CurFn);
>
> + /// Return the size reported by the variable's type.
> + unsigned getSizeInBits(const DITypeIdentifierMap &Map);
> +
> + void printExtendedName(raw_ostream &OS) const;
> +};
> +
> +/// DIExpression - A complex location expression.
> +class DIExpression : public DIDescriptor {
> + friend class DIDescriptor;
> + void printInternal(raw_ostream &OS) const;
> +
> +public:
> + explicit DIExpression(const MDNode *N = nullptr) : DIDescriptor(N) {}
> +
> + /// Verify - Verify that a variable descriptor is well formed.
> + bool Verify() const;
> +
> + /// \brief Return the number of elements in the complex expression.
> + unsigned getNumElements() const {
> + if (!DbgNode)
> + return 0;
> + unsigned N = DbgNode->getNumOperands();
> + assert(N > 0 && "missing tag");
> + return N - 1;
> + }
> +
> + /// \brief return the Idx'th complex address element.
> + uint64_t getElement(unsigned Idx) const;
> +
> /// isVariablePiece - Return whether this is a piece of an aggregate
> /// variable.
> bool isVariablePiece() const;
> @@ -751,11 +767,6 @@ public:
> uint64_t getPieceOffset() const;
> /// getPieceSize - Return the size of this piece in bytes.
> uint64_t getPieceSize() const;
> -
> - /// Return the size reported by the variable's type.
> - unsigned getSizeInBits(const DITypeIdentifierMap &Map);
> -
> - void printExtendedName(raw_ostream &OS) const;
> };
>
> /// DILocation - This object holds location information. This object
> @@ -872,9 +883,6 @@ DIVariable createInlinedVariable(MDNode
> /// cleanseInlinedVariable - Remove inlined scope from the variable.
> DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
>
> -/// getEntireVariable - Remove OpPiece exprs from the variable.
> -DIVariable getEntireVariable(DIVariable DV);
> -
> /// Construct DITypeIdentifierMap by going through retained types of each
> CU.
> DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode
> *CU_Nodes);
>
>
> Modified: llvm/trunk/include/llvm/IR/IntrinsicInst.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/IR/IntrinsicInst.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/IntrinsicInst.h (original)
> +++ llvm/trunk/include/llvm/IR/IntrinsicInst.h Wed Oct 1 13:55:02 2014
> @@ -82,6 +82,7 @@ namespace llvm {
> public:
> Value *getAddress() const;
> MDNode *getVariable() const { return cast<MDNode>(getArgOperand(1));
> }
> + MDNode *getExpression() const { return cast<MDNode>(getArgOperand(2));
> }
>
> // Methods for support type inquiry through isa, cast, and dyn_cast:
> static inline bool classof(const IntrinsicInst *I) {
> @@ -103,6 +104,7 @@ namespace llvm {
> const_cast<Value*>(getArgOperand(1)))->
> getZExtValue();
> }
> MDNode *getVariable() const { return cast<MDNode>(getArgOperand(2));
> }
> + MDNode *getExpression() const { return cast<MDNode>(getArgOperand(3));
> }
>
> // Methods for support type inquiry through isa, cast, and dyn_cast:
> static inline bool classof(const IntrinsicInst *I) {
>
> Modified: llvm/trunk/include/llvm/IR/Intrinsics.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/IR/Intrinsics.td?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/IR/Intrinsics.td (original)
> +++ llvm/trunk/include/llvm/IR/Intrinsics.td Wed Oct 1 13:55:02 2014
> @@ -373,9 +373,12 @@ let Properties = [IntrNoMem] in {
> // places.
> let Properties = [IntrNoMem] in {
> def int_dbg_declare : Intrinsic<[],
> - [llvm_metadata_ty,
> llvm_metadata_ty]>;
> + [llvm_metadata_ty,
> + llvm_metadata_ty,
> + llvm_metadata_ty]>;
> def int_dbg_value : Intrinsic<[],
> [llvm_metadata_ty, llvm_i64_ty,
> + llvm_metadata_ty,
> llvm_metadata_ty]>;
> }
>
>
> Modified: llvm/trunk/include/llvm/Support/Dwarf.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/Support/Dwarf.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/Support/Dwarf.h (original)
> +++ llvm/trunk/include/llvm/Support/Dwarf.h Wed Oct 1 13:55:02 2014
> @@ -53,6 +53,7 @@ enum LLVMConstants : uint32_t {
>
> DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
> DW_TAG_arg_variable = 0x101, // Tag for argument variables.
> + DW_TAG_expression = 0x102, // Tag for complex address expressions.
>
> DW_TAG_user_base = 0x1000, // Recommended base for user tags.
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/AsmPrinter.cpp?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Oct 1 13:55:02
> 2014
> @@ -614,8 +614,8 @@ static void emitKill(const MachineInstr
> /// of DBG_VALUE, returning true if it was able to do so. A false return
> /// means the target will need to handle MI in EmitInstruction.
> static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP)
> {
> - // This code handles only the 3-operand target-independent form.
> - if (MI->getNumOperands() != 3)
> + // This code handles only the 4-operand target-independent form.
> + if (MI->getNumOperands() != 4)
> return false;
>
> SmallString<128> Str;
> @@ -629,9 +629,11 @@ static bool emitDebugValueComment(const
> OS << Name << ":";
> }
> OS << V.getName();
> - if (V.isVariablePiece())
> - OS << " [piece offset=" << V.getPieceOffset()
> - << " size="<<V.getPieceSize()<<"]";
> +
> + DIExpression Expr = MI->getDebugExpression();
> + if (Expr.isVariablePiece())
> + OS << " [piece offset=" << Expr.getPieceOffset()
> + << " size=" << Expr.getPieceSize() << "]";
> OS << " <- ";
>
> // The second operand is only an offset if it's an immediate.
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp?rev=218787&r1=218786&r2=
> 218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp
> (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DbgValueHistoryCalculator.cpp Wed
> Oct 1 13:55:02 2014
> @@ -27,7 +27,7 @@ namespace llvm {
> // In the other case, returns 0.
> static unsigned isDescribedByReg(const MachineInstr &MI) {
> assert(MI.isDebugValue());
> - assert(MI.getNumOperands() == 3);
> + assert(MI.getNumOperands() == 4);
> // If location of variable is described using a register (directly or
> // indirecltly), this register is always a first operand.
> return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0;
> @@ -37,7 +37,7 @@ void DbgValueHistoryMap::startInstrRange
> const MachineInstr &MI) {
> // Instruction range should start with a DBG_VALUE instruction for the
> // variable.
> - assert(MI.isDebugValue() && getEntireVariable(MI.getDebugVariable())
> == Var);
> + assert(MI.isDebugValue() && "not a DBG_VALUE");
> auto &Ranges = VarInstrRanges[Var];
> if (!Ranges.empty() && Ranges.back().second == nullptr &&
> Ranges.back().first->isIdenticalTo(&MI)) {
> @@ -193,7 +193,7 @@ void calculateDbgValueHistory(const Mach
> // Use the base variable (without any DW_OP_piece expressions)
> // as index into History. The full variables including the
> // piece expressions are attached to the MI.
> - DIVariable Var = getEntireVariable(MI.getDebugVariable());
> + DIVariable Var = MI.getDebugVariable();
>
> if (unsigned PrevReg = Result.getRegisterForVar(Var))
> dropRegDescribedVar(RegVars, PrevReg, Var);
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DebugLocEntry.h?rev=218787&r1=
> 218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugLocEntry.h Wed Oct 1 13:55:02
> 2014
> @@ -26,25 +26,30 @@ class DebugLocEntry {
> public:
> /// A single location or constant.
> struct Value {
> - Value(const MDNode *Var, int64_t i)
> - : Variable(Var), EntryKind(E_Integer) {
> + Value(const MDNode *Var, const MDNode *Expr, int64_t i)
> + : Variable(Var), Expression(Expr), EntryKind(E_Integer) {
> Constant.Int = i;
> }
> - Value(const MDNode *Var, const ConstantFP *CFP)
> - : Variable(Var), EntryKind(E_ConstantFP) {
> + Value(const MDNode *Var, const MDNode *Expr, const ConstantFP *CFP)
> + : Variable(Var), Expression(Expr), EntryKind(E_ConstantFP) {
> Constant.CFP = CFP;
> }
> - Value(const MDNode *Var, const ConstantInt *CIP)
> - : Variable(Var), EntryKind(E_ConstantInt) {
> + Value(const MDNode *Var, const MDNode *Expr, const ConstantInt *CIP)
> + : Variable(Var), Expression(Expr), EntryKind(E_ConstantInt) {
> Constant.CIP = CIP;
> }
> - Value(const MDNode *Var, MachineLocation Loc)
> - : Variable(Var), EntryKind(E_Location), Loc(Loc) {
> + Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc)
> + : Variable(Var), Expression(Expr), EntryKind(E_Location),
> Loc(Loc) {
> + assert(DIVariable(Var).Verify());
> + assert(DIExpression(Expr).Verify());
> }
>
> // The variable to which this location entry corresponds.
> const MDNode *Variable;
>
> + // Any complex address location expression for this Value.
> + const MDNode *Expression;
> +
> // Type of entry that this represents.
> enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
> enum EntryType EntryKind;
> @@ -69,7 +74,8 @@ public:
> MachineLocation getLoc() const { return Loc; }
> const MDNode *getVariableNode() const { return Variable; }
> DIVariable getVariable() const { return DIVariable(Variable); }
> - bool isVariablePiece() const { return getVariable().isVariablePiece();
> }
> + bool isVariablePiece() const { return getExpression().isVariablePiece();
> }
> + DIExpression getExpression() const { return DIExpression(Expression);
> }
> friend bool operator==(const Value &, const Value &);
> friend bool operator<(const Value &, const Value &);
> };
> @@ -90,11 +96,13 @@ public:
> // list of values.
> // Return true if the merge was successful.
> bool MergeValues(const DebugLocEntry &Next) {
> - if (Begin == Next.Begin && Values.size() > 0 && Next.Values.size() >
> 0) {
> + if (Begin == Next.Begin) {
> + DIExpression Expr(Values[0].Expression);
> DIVariable Var(Values[0].Variable);
> + DIExpression NextExpr(Next.Values[0].Expression);
> DIVariable NextVar(Next.Values[0].Variable);
> - if (Var.getName() == NextVar.getName() &&
> - Var.isVariablePiece() && NextVar.isVariablePiece()) {
> + if (Var == NextVar && Expr.isVariablePiece() &&
> + NextExpr.isVariablePiece()) {
> addValues(Next.Values);
> End = Next.End;
> return true;
> @@ -133,8 +141,10 @@ public:
> std::sort(Values.begin(), Values.end());
> Values.erase(std::unique(Values.begin(), Values.end(),
> [](const Value &A, const Value &B) {
> - return A.getVariable() == B.getVariable();
> - }), Values.end());
> + return A.getVariable() == B.getVariable() &&
> + A.getExpression() == B.getExpression();
> + }),
> + Values.end());
> }
> };
>
> @@ -144,7 +154,10 @@ inline bool operator==(const DebugLocEnt
> if (A.EntryKind != B.EntryKind)
> return false;
>
> - if (A.getVariable() != B.getVariable())
> + if (A.Expression != B.Expression)
> + return false;
> +
> + if (A.Variable != B.Variable)
> return false;
>
> switch (A.EntryKind) {
> @@ -163,7 +176,8 @@ inline bool operator==(const DebugLocEnt
> /// Compare two pieces based on their offset.
> inline bool operator<(const DebugLocEntry::Value &A,
> const DebugLocEntry::Value &B) {
> - return A.getVariable().getPieceOffset() < B.getVariable().
> getPieceOffset();
> + return A.getExpression().getPieceOffset() <
> + B.getExpression().getPieceOffset();
> }
>
> }
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfDebug.cpp?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Oct 1 13:55:02
> 2014
> @@ -901,7 +901,7 @@ void DwarfDebug::collectDeadVariables()
> for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve;
> ++vi) {
> DIVariable DV(Variables.getElement(vi));
> assert(DV.isVariable());
> - DbgVariable NewVar(DV, this);
> + DbgVariable NewVar(DV, DIExpression(nullptr), this);
> auto VariableDie = SPCU->constructVariableDIE(NewVar);
> SPCU->applyVariableAttributes(NewVar, *VariableDie);
> SPDIE->addChild(std::move(VariableDie));
> @@ -1121,7 +1121,7 @@ DbgVariable *DwarfDebug::getExistingAbst
>
> void DwarfDebug::createAbstractVariable(const DIVariable &Var,
> LexicalScope *Scope) {
> - auto AbsDbgVariable = make_unique<DbgVariable>(Var, this);
> + auto AbsDbgVariable = make_unique<DbgVariable>(Var, DIExpression(),
> this);
> addScopeVariable(Scope, AbsDbgVariable.get());
> AbstractVariables[Var] = std::move(AbsDbgVariable);
> }
> @@ -1177,6 +1177,7 @@ void DwarfDebug::collectVariableInfoFrom
> continue;
> Processed.insert(VI.Var);
> DIVariable DV(VI.Var);
> + DIExpression Expr(VI.Expr);
> LexicalScope *Scope = LScopes.findLexicalScope(VI.Loc);
>
> // If variable scope is not found then skip this variable.
> @@ -1184,7 +1185,7 @@ void DwarfDebug::collectVariableInfoFrom
> continue;
>
> ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
> - ConcreteVariables.push_back(make_unique<DbgVariable>(DV, this));
> + ConcreteVariables.push_back(make_unique<DbgVariable>(DV, Expr,
> this));
> DbgVariable *RegVar = ConcreteVariables.back().get();
> RegVar->setFrameIndex(VI.Slot);
> addScopeVariable(Scope, RegVar);
> @@ -1193,9 +1194,10 @@ void DwarfDebug::collectVariableInfoFrom
>
> // Get .debug_loc entry for the instruction range starting at MI.
> static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
> + const MDNode *Expr = MI->getDebugExpression();
> const MDNode *Var = MI->getDebugVariable();
>
> - assert(MI->getNumOperands() == 3);
> + assert(MI->getNumOperands() == 4);
> if (MI->getOperand(0).isReg()) {
> MachineLocation MLoc;
> // If the second operand is an immediate, this is a
> @@ -1204,20 +1206,20 @@ static DebugLocEntry::Value getDebugLocV
> MLoc.set(MI->getOperand(0).getReg());
> else
> MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
> - return DebugLocEntry::Value(Var, MLoc);
> + return DebugLocEntry::Value(Var, Expr, MLoc);
> }
> if (MI->getOperand(0).isImm())
> - return DebugLocEntry::Value(Var, MI->getOperand(0).getImm());
> + return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getImm());
> if (MI->getOperand(0).isFPImm())
> - return DebugLocEntry::Value(Var, MI->getOperand(0).getFPImm());
> + return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getFPImm());
> if (MI->getOperand(0).isCImm())
> - return DebugLocEntry::Value(Var, MI->getOperand(0).getCImm());
> + return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getCImm());
>
> - llvm_unreachable("Unexpected 3 operand DBG_VALUE instruction!");
> + llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!");
> }
>
> /// Determine whether two variable pieces overlap.
> -static bool piecesOverlap(DIVariable P1, DIVariable P2) {
> +static bool piecesOverlap(DIExpression P1, DIExpression P2) {
> if (!P1.isVariablePiece() || !P2.isVariablePiece())
> return true;
> unsigned l1 = P1.getPieceOffset();
> @@ -1268,11 +1270,11 @@ DwarfDebug::buildLocationList(SmallVecto
> }
>
> // If this piece overlaps with any open ranges, truncate them.
> - DIVariable DIVar = Begin->getDebugVariable();
> + DIExpression DIExpr = Begin->getDebugExpression();
> auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
> [&](DebugLocEntry::Value R) {
> - return piecesOverlap(DIVar,
> R.getVariable());
> - });
> + return piecesOverlap(DIExpr, R.getExpression());
> + });
> OpenRanges.erase(Last, OpenRanges.end());
>
> const MCSymbol *StartLabel = getLabelBeforeInsn(Begin);
> @@ -1294,7 +1296,7 @@ DwarfDebug::buildLocationList(SmallVecto
> bool couldMerge = false;
>
> // If this is a piece, it may belong to the current DebugLocEntry.
> - if (DIVar.isVariablePiece()) {
> + if (DIExpr.isVariablePiece()) {
> // Add this value to the list of open ranges.
> OpenRanges.push_back(Value);
>
> @@ -1320,10 +1322,14 @@ DwarfDebug::buildLocationList(SmallVecto
> if (PrevEntry != DebugLoc.rend() && PrevEntry->MergeRanges(*
> CurEntry))
> DebugLoc.pop_back();
>
> - DEBUG(dbgs() << "Values:\n";
> - for (auto Value : CurEntry->getValues())
> - Value.getVariable()->dump();
> - dbgs() << "-----\n");
> + DEBUG({
> + dbgs() << CurEntry->getValues().size() << " Values:\n";
> + for (auto Value : CurEntry->getValues()) {
> + Value.getVariable()->dump();
> + Value.getExpression()->dump();
> + }
> + dbgs() << "-----\n";
> + });
> }
> }
>
> @@ -1358,7 +1364,7 @@ DwarfDebug::collectVariableInfo(SmallPtr
> if (!Scope)
> continue;
>
> - Processed.insert(getEntireVariable(DV));
> + Processed.insert(DV);
> const MachineInstr *MInsn = Ranges.front().first;
> assert(MInsn->isDebugValue() && "History must begin with debug
> value");
> ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
> @@ -1392,7 +1398,8 @@ DwarfDebug::collectVariableInfo(SmallPtr
> continue;
> if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext()))
> {
> ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
> - ConcreteVariables.push_back(make_unique<DbgVariable>(DV, this));
> + DIExpression NoExpr;
> + ConcreteVariables.push_back(make_unique<DbgVariable>(DV, NoExpr,
> this));
> addScopeVariable(Scope, ConcreteVariables.back().get());
> }
> }
> @@ -1580,18 +1587,17 @@ void DwarfDebug::beginFunction(const Mac
>
> // The first mention of a function argument gets the FunctionBeginSym
> // label, so arguments are visible when breaking at function entry.
> - DIVariable DV(Ranges.front().first->getDebugVariable());
> - if (DV.isVariable() && DV.getTag() == dwarf::DW_TAG_arg_variable &&
> - getDISubprogram(DV.getContext()).describes(MF->getFunction())) {
> - if (!DV.isVariablePiece())
> - LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym;
> - else {
> + DIVariable DIVar(Ranges.front().first->getDebugVariable());
> + if (DIVar.isVariable() && DIVar.getTag() ==
> dwarf::DW_TAG_arg_variable &&
> + getDISubprogram(DIVar.getContext()).describes(MF->getFunction()))
> {
> + LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym;
> + if (Ranges.front().first->getDebugExpression().isVariablePiece()) {
> // Mark all non-overlapping initial pieces.
> for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
> - DIVariable Piece = I->first->getDebugVariable();
> + DIExpression Piece = I->first->getDebugExpression();
> if (std::all_of(Ranges.begin(), I,
> - [&](DbgValueHistoryMap::InstrRange Pred){
> - return !piecesOverlap(Piece,
> Pred.first->getDebugVariable());
> + [&](DbgValueHistoryMap::InstrRange Pred) {
> + return !piecesOverlap(Piece, Pred.first->
> getDebugExpression());
> }))
> LabelsBeforeInsn[I->first] = FunctionBeginSym;
> else
> @@ -2089,9 +2095,9 @@ void DwarfDebug::emitLocPieces(ByteStrea
>
> unsigned Offset = 0;
> for (auto Piece : Values) {
> - DIVariable Var = Piece.getVariable();
> - unsigned PieceOffset = Var.getPieceOffset();
> - unsigned PieceSize = Var.getPieceSize();
> + DIExpression Expr = Piece.getExpression();
> + unsigned PieceOffset = Expr.getPieceOffset();
> + unsigned PieceSize = Expr.getPieceSize();
> assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
> if (Offset < PieceOffset) {
> // The DWARF spec seriously mandates pieces with no locations for
> gaps.
> @@ -2102,8 +2108,9 @@ void DwarfDebug::emitLocPieces(ByteStrea
> Offset += PieceSize;
>
> const unsigned SizeOfByte = 8;
> - assert(!Var.isIndirect() && "indirect address for piece");
> #ifndef NDEBUG
> + DIVariable Var = Piece.getVariable();
> + assert(!Var.isIndirect() && "indirect address for piece");
> unsigned VarSize = Var.getSizeInBits(Map);
> assert(PieceSize+PieceOffset <= VarSize/SizeOfByte
> && "piece is larger than or outside of variable");
> @@ -2149,24 +2156,25 @@ void DwarfDebug::emitDebugLocValue(ByteS
> }
> } else if (Value.isLocation()) {
> MachineLocation Loc = Value.getLoc();
> - if (!DV.hasComplexAddress())
> + DIExpression Expr = Value.getExpression();
> + if (!Expr)
> // Regular entry.
> Asm->EmitDwarfRegOp(Streamer, Loc, DV.isIndirect());
> else {
> // Complex address entry.
> - unsigned N = DV.getNumAddrElements();
> + unsigned N = Expr.getNumElements();
> unsigned i = 0;
> - if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
> + if (N >= 2 && Expr.getElement(0) == dwarf::DW_OP_plus) {
> if (Loc.getOffset()) {
> i = 2;
> Asm->EmitDwarfRegOp(Streamer, Loc, DV.isIndirect());
> Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
> Streamer.EmitInt8(dwarf::DW_OP_plus_uconst,
> "DW_OP_plus_uconst");
> - Streamer.EmitSLEB128(DV.getAddrElement(1));
> + Streamer.EmitSLEB128(Expr.getElement(1));
> } else {
> // If first address element is OpPlus then emit
> // DW_OP_breg + Offset instead of DW_OP_reg + Offset.
> - MachineLocation TLoc(Loc.getReg(), DV.getAddrElement(1));
> + MachineLocation TLoc(Loc.getReg(), Expr.getElement(1));
> Asm->EmitDwarfRegOp(Streamer, TLoc, DV.isIndirect());
> i = 2;
> }
> @@ -2176,14 +2184,14 @@ void DwarfDebug::emitDebugLocValue(ByteS
>
> // Emit remaining complex address elements.
> for (; i < N; ++i) {
> - uint64_t Element = DV.getAddrElement(i);
> - if (Element == DIBuilder::OpPlus) {
> + uint64_t Element = Expr.getElement(i);
> + if (Element == dwarf::DW_OP_plus) {
> Streamer.EmitInt8(dwarf::DW_OP_plus_uconst,
> "DW_OP_plus_uconst");
> - Streamer.EmitULEB128(DV.getAddrElement(++i));
> - } else if (Element == DIBuilder::OpDeref) {
> + Streamer.EmitULEB128(Expr.getElement(++i));
> + } else if (Element == dwarf::DW_OP_deref) {
> if (!Loc.isReg())
> Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
> - } else if (Element == DIBuilder::OpPiece) {
> + } else if (Element == dwarf::DW_OP_piece) {
> i += 3;
> // handled in emitDebugLocEntry.
> } else
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfDebug.h?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Oct 1 13:55:02
> 2014
> @@ -70,6 +70,7 @@ public:
> /// \brief This class is used to track local variable information.
> class DbgVariable {
> DIVariable Var; // Variable Descriptor.
> + DIExpression Expr; // Complex address location expression.
> DIE *TheDIE; // Variable DIE.
> unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
> const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
> @@ -78,18 +79,22 @@ class DbgVariable {
>
> public:
> /// Construct a DbgVariable from a DIVariable.
> - DbgVariable(DIVariable V, DwarfDebug *DD)
> - : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(nullptr),
> - FrameIndex(~0), DD(DD) {}
> + DbgVariable(DIVariable V, DIExpression E, DwarfDebug *DD)
> + : Var(V), Expr(E), TheDIE(nullptr), DotDebugLocOffset(~0U),
> + MInsn(nullptr), FrameIndex(~0), DD(DD) {
> + assert(Var.Verify() && Expr.Verify());
> + }
>
> /// Construct a DbgVariable from a DEBUG_VALUE.
> /// AbstractVar may be NULL.
> DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
> - : Var(DbgValue->getDebugVariable()), TheDIE(nullptr),
> - DotDebugLocOffset(~0U), MInsn(DbgValue), FrameIndex(~0), DD(DD) {}
> + : Var(DbgValue->getDebugVariable()), Expr(DbgValue->
> getDebugExpression()),
> + TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(DbgValue),
> + FrameIndex(~0), DD(DD) {}
>
> // Accessors.
> DIVariable getVariable() const { return Var; }
> + DIExpression getExpression() const { return Expr; }
> void setDIE(DIE &D) { TheDIE = &D; }
> DIE *getDIE() const { return TheDIE; }
> void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
> @@ -124,14 +129,14 @@ public:
>
> bool variableHasComplexAddress() const {
> assert(Var.isVariable() && "Invalid complex DbgVariable!");
> - return Var.hasComplexAddress();
> + return Expr.getNumElements() > 0;
> }
> bool isBlockByrefVariable() const;
> unsigned getNumAddrElements() const {
> assert(Var.isVariable() && "Invalid complex DbgVariable!");
> - return Var.getNumAddrElements();
> + return Expr.getNumElements();
> }
> - uint64_t getAddrElement(unsigned i) const { return
> Var.getAddrElement(i); }
> + uint64_t getAddrElement(unsigned i) const { return Expr.getElement(i); }
> DIType getType() const;
>
> private:
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfUnit.cpp?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Oct 1 13:55:02
> 2014
> @@ -607,16 +607,20 @@ void DwarfUnit::addComplexAddress(const
> unsigned N = DV.getNumAddrElements();
> unsigned i = 0;
> if (Location.isReg()) {
> - if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
> + if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_plus) {
> + assert(!DV.getVariable().isIndirect() &&
> + "double indirection not handled");
> // If first address element is OpPlus then emit
> // DW_OP_breg + Offset instead of DW_OP_reg + Offset.
> addRegisterOffset(*Loc, Location.getReg(), DV.getAddrElement(1));
> i = 2;
> - } else if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpDeref) {
> - addRegisterOpPiece(*Loc, Location.getReg(),
> - DV.getVariable().getPieceSize(),
> - DV.getVariable().getPieceOffset());
> - i = 3;
> + } else if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_deref) {
> + assert(!DV.getVariable().isIndirect() &&
> + "double indirection not handled");
> + addRegisterOpPiece(*Loc, Location.getReg(),
> + DV.getExpression().getPieceSize(),
> + DV.getExpression().getPieceOffset());
> + i = 3;
> } else
> addRegisterOpPiece(*Loc, Location.getReg());
> } else
> @@ -624,15 +628,15 @@ void DwarfUnit::addComplexAddress(const
>
> for (; i < N; ++i) {
> uint64_t Element = DV.getAddrElement(i);
> - if (Element == DIBuilder::OpPlus) {
> + if (Element == dwarf::DW_OP_plus) {
> addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
> addUInt(*Loc, dwarf::DW_FORM_udata, DV.getAddrElement(++i));
>
> - } else if (Element == DIBuilder::OpDeref) {
> + } else if (Element == dwarf::DW_OP_deref) {
> if (!Location.isReg())
> addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
>
> - } else if (Element == DIBuilder::OpPiece) {
> + } else if (Element == dwarf::DW_OP_piece) {
> const unsigned SizeOfByte = 8;
> unsigned PieceOffsetInBits = DV.getAddrElement(++i)*SizeOfByte;
> unsigned PieceSizeInBits = DV.getAddrElement(++i)*SizeOfByte;
> @@ -1861,7 +1865,7 @@ std::unique_ptr<DIE> DwarfUnit::construc
>
> // Check if variable is described by a DBG_VALUE instruction.
> if (const MachineInstr *DVInsn = DV.getMInsn()) {
> - assert(DVInsn->getNumOperands() == 3);
> + assert(DVInsn->getNumOperands() == 4);
> if (DVInsn->getOperand(0).isReg()) {
> const MachineOperand RegOp = DVInsn->getOperand(0);
> // If the second operand is an immediate, this is an indirect value.
>
> Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/InlineSpiller.cpp?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
> +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Wed Oct 1 13:55:02 2014
> @@ -1224,12 +1224,16 @@ void InlineSpiller::spillAroundUses(unsi
> // Modify DBG_VALUE now that the value is in a spill slot.
> bool IsIndirect = MI->isIndirectDebugValue();
> uint64_t Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
> - const MDNode *MDPtr = MI->getOperand(2).getMetadata();
> + const MDNode *Var = MI->getDebugVariable();
> + const MDNode *Expr = MI->getDebugExpression();
> DebugLoc DL = MI->getDebugLoc();
> DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" <<
> *MI);
> MachineBasicBlock *MBB = MI->getParent();
> BuildMI(*MBB, MBB->erase(MI), DL, TII.get(TargetOpcode::DBG_VALUE))
> - .addFrameIndex(StackSlot).addImm(Offset).addMetadata(MDPtr);
> + .addFrameIndex(StackSlot)
> + .addImm(Offset)
> + .addMetadata(Var)
> + .addMetadata(Expr);
> continue;
> }
>
>
> Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/LiveDebugVariables.cpp?rev=218787&r1=218786&r2=218787&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Wed Oct 1 13:55:02 2014
> @@ -110,7 +110,8 @@ public:
> namespace {
> class LDVImpl;
> class UserValue {
> - const MDNode *variable; ///< The debug info variable we are part of.
> + const MDNode *Variable; ///< The debug info variable we are part of.
> + const MDNode *Expression; ///< Any complex address expression.
> unsigned offset; ///< Byte offset into variable.
> bool IsIndirect; ///< true if this is a register-indirect+offset
> value.
> DebugLoc dl; ///< The debug location for the variable. This
> is
> @@ -140,11 +141,10 @@ class UserValue {
>
> public:
> /// UserValue - Create a new UserValue.
> - UserValue(const MDNode *var, unsigned o, bool i, DebugLoc L,
> - LocMap::Allocator &alloc)
> - : variable(var), offset(o), IsIndirect(i), dl(L), leader(this),
> - next(nullptr), locInts(alloc)
> - {}
> + UserValue(const MDNode *var, const MDNode *expr, unsigned o, bool i,
> + DebugLoc L, LocMap::Allocator &alloc)
> + : Variable(var), Expression(expr), offset(o), IsIndirect(i), dl(L),
> + leader(this), next(nullptr), locInts(alloc) {}
>
> /// getLeader - Get the leader of this value's equivalence class.
> UserValue *getLeader() {
> @@ -158,8 +158,10 @@ public:
> UserValue *getNext() const { return next; }
>
> /// match - Does this UserValue match the parameters?
> - bool match(const MDNode *Var, unsigned Offset, bool indirect) const {
> - return Var == variable && Offset == offset && indirect == IsIndirect;
> + bool match(const MDNode *Var, const MDNode *Expr, unsigned Offset,
> + bool indirect) const {
> + return Var == Variable && Expr == Expression && Offset == offset &&
> + indirect == IsIndirect;
> }
>
> /// merge - Merge equivalence classes.
> @@ -307,8 +309,8 @@ class LDVImpl {
> UVMap userVarMap;
>
> /// getUserValue - Find or create a UserValue.
> - UserValue *getUserValue(const MDNode *Var, unsigned Offset,
> - bool IsIndirect, DebugLoc DL);
> + UserValue *getUserValue(const MDNode *Var, const MDNode *Expr,
> + unsigned Offset, bool IsIndirect, DebugLoc DL);
>
> /// lookupVirtReg - Find the EC leader for VirtReg or null.
> UserValue *lookupVirtReg(unsigned VirtReg);
> @@ -361,7 +363,7 @@ public:
> } // namespace
>
> void UserValue::print(raw_ostream &OS, const TargetMachine *TM) {
> - DIVariable DV(variable);
> + DIVariable DV(Variable);
> OS << "!\"";
> DV.printExtendedName(OS);
> OS << "\"\t";
> @@ -422,19 +424,20 @@ void UserValue::mapVirtRegs(LDVImpl *LDV
> LDV->mapVirtReg(locations[i].getReg(), this);
> }
>
> -UserValue *LDVImpl::getUserValue(const MDNode *Var, unsigned Offset,
> -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141002/d8c4aa71/attachment.html>
More information about the llvm-commits
mailing list