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