From 5d0334a48ca57a6d1fe799f120629ea06563239c Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 28 Jul 2017 20:21:02 +0000 Subject: [PATCH] Remove the obsolete offset parameter from @llvm.dbg.value There is no situation where this rarely-used argument cannot be substituted with a DIExpression and removing it allows us to simplify the DWARF backend. Note that this patch does not yet remove any of the newly dead code. rdar://problem/33580047 Differential Revision: https://reviews.llvm.org/D35951 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309426 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LangRef.rst | 2 +- docs/SourceLevelDebugging.rst | 11 +++---- include/llvm/IR/DIBuilder.h | 6 ++-- include/llvm/IR/IntrinsicInst.h | 9 ++---- include/llvm/IR/Intrinsics.td | 2 +- lib/CodeGen/GlobalISel/IRTranslator.cpp | 11 ++----- lib/CodeGen/SelectionDAG/FastISel.cpp | 14 ++++----- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 4 +-- lib/IR/AutoUpgrade.cpp | 22 +++++++++++++ lib/IR/DIBuilder.cpp | 6 ++-- lib/Transforms/Utils/Local.cpp | 17 +++++------ test/Bitcode/upgrade-dbg-value.ll | 32 +++++++++++++++++++ test/Bitcode/upgrade-dbg-value.ll.bc | Bin 0 -> 1452 bytes test/CodeGen/ARM/2010-04-15-ScavengerDebugValue.ll | 4 +-- .../ARM/2010-06-25-Thumb2ITInvalidIterator.ll | 10 +++--- test/CodeGen/ARM/2010-08-04-StackVariable.ll | 10 +++--- test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll | 22 ++++++------- test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll | 22 ++++++------- .../CodeGen/ARM/2016-08-24-ARM-LDST-dbginfo-bug.ll | 6 ++-- test/CodeGen/ARM/coalesce-dbgvalue.ll | 6 ++-- test/CodeGen/ARM/debug-info-arg.ll | 14 ++++----- test/CodeGen/ARM/debug-info-blocks.ll | 4 +-- test/CodeGen/ARM/debug-info-branch-folding.ll | 6 ++-- test/CodeGen/ARM/debug-info-d16-reg.ll | 26 ++++++++-------- test/CodeGen/ARM/debug-info-qreg.ll | 4 +-- test/CodeGen/ARM/debug-info-s16-reg.ll | 26 ++++++++-------- test/CodeGen/ARM/debug-info-sreg2.ll | 4 +-- test/DebugInfo/AArch64/cfi-eof-prologue.ll | 8 ++--- test/DebugInfo/AArch64/coalescing.ll | 4 +-- test/DebugInfo/AArch64/frameindices.ll | 16 +++++----- test/DebugInfo/AMDGPU/dbg-value-sched-crash.ll | 6 ++-- test/DebugInfo/ARM/PR16736.ll | 14 ++++----- test/DebugInfo/ARM/PR26163.ll | 8 ++--- test/DebugInfo/ARM/cfi-eof-prologue.ll | 8 ++--- test/DebugInfo/ARM/float-args.ll | 4 +-- test/DebugInfo/ARM/lowerbdgdeclare_vla.ll | 8 ++--- test/DebugInfo/ARM/partial-subreg.ll | 6 ++-- test/DebugInfo/ARM/s-super-register.ll | 4 +-- test/DebugInfo/ARM/split-complex.ll | 6 ++-- test/DebugInfo/ARM/sroa-complex.ll | 4 +-- test/DebugInfo/COFF/comdat.ll | 8 ++--- test/DebugInfo/COFF/fp-stack.ll | 4 +-- test/DebugInfo/COFF/local-constant.ll | 4 +-- test/DebugInfo/COFF/local-variable-gap.ll | 4 +-- test/DebugInfo/COFF/pieces.ll | 28 ++++++++--------- test/DebugInfo/COFF/register-variables.ll | 14 ++++----- test/DebugInfo/COFF/types-calling-conv.ll | 4 +-- test/DebugInfo/Generic/2009-11-10-CurrentFn.ll | 2 +- test/DebugInfo/Generic/2010-05-03-OriginDIE.ll | 8 ++--- .../Generic/2010-06-29-InlinedFnLocalVar.ll | 4 +-- test/DebugInfo/Generic/dead-argument-order.ll | 4 +-- test/DebugInfo/Generic/gvn.ll | 4 +-- .../Generic/incorrect-variable-debugloc.ll | 6 ++-- .../Generic/incorrect-variable-debugloc1.ll | 8 ++--- test/DebugInfo/Generic/inlined-arguments.ll | 10 +++--- test/DebugInfo/Generic/inlined-vars.ll | 6 ++-- .../DebugInfo/Generic/missing-abstract-variable.ll | 10 +++--- test/DebugInfo/Generic/piece-verifier.ll | 6 ++-- test/DebugInfo/Generic/recursive_inlining.ll | 10 +++--- test/DebugInfo/Generic/sugared-constants.ll | 8 ++--- test/DebugInfo/Generic/two-cus-from-same-file.ll | 6 ++-- test/DebugInfo/Mips/InlinedFnLocalVar.ll | 4 +-- test/DebugInfo/Mips/delay-slot.ll | 4 +-- test/DebugInfo/Mips/dsr-fixed-objects.ll | 34 ++++++++++----------- test/DebugInfo/X86/DW_AT_calling-convention.ll | 6 ++-- test/DebugInfo/X86/DW_AT_location-reference.ll | 10 +++--- test/DebugInfo/X86/InlinedFnLocalVar.ll | 4 +-- test/DebugInfo/X86/PR26148.ll | 14 ++++----- test/DebugInfo/X86/array.ll | 8 ++--- test/DebugInfo/X86/array2.ll | 2 +- test/DebugInfo/X86/bbjoin.ll | 12 ++++---- test/DebugInfo/X86/block-capture.ll | 4 +-- test/DebugInfo/X86/constant-aggregate.ll | 12 ++++---- test/DebugInfo/X86/constant-loclist.ll | 12 ++++---- test/DebugInfo/X86/dbg-const-int.ll | 4 +-- test/DebugInfo/X86/dbg-const.ll | 6 ++-- test/DebugInfo/X86/dbg-i128-const.ll | 4 +-- test/DebugInfo/X86/dbg-merge-loc-entry.ll | 8 ++--- test/DebugInfo/X86/dbg-value-const-byref.ll | 10 +++--- test/DebugInfo/X86/dbg-value-dag-combine.ll | 10 +++--- test/DebugInfo/X86/dbg-value-frame-index.ll | 4 +-- test/DebugInfo/X86/dbg-value-g-gmlt.ll | 6 ++-- test/DebugInfo/X86/dbg-value-inlined-parameter.ll | 10 +++--- test/DebugInfo/X86/dbg-value-isel.ll | 10 +++--- test/DebugInfo/X86/dbg-value-location.ll | 4 +-- test/DebugInfo/X86/dbg-value-range.ll | 6 ++-- test/DebugInfo/X86/dbg-value-regmask-clobber.ll | 6 ++-- test/DebugInfo/X86/dbg-value-terminator.ll | 4 +-- test/DebugInfo/X86/debug-info-blocks.ll | 4 +-- test/DebugInfo/X86/debug-loc-frame.ll | 6 ++-- test/DebugInfo/X86/debug-ranges-offset.ll | 10 +++--- test/DebugInfo/X86/deleted-bit-piece.ll | 4 +-- test/DebugInfo/X86/dw_op_minus_direct.ll | 4 +-- .../DebugInfo/X86/dwarf-aranges-no-dwarf-labels.ll | 6 ++-- test/DebugInfo/X86/earlydup-crash.ll | 4 +-- test/DebugInfo/X86/elf-names.ll | 8 ++--- test/DebugInfo/X86/fission-ranges.ll | 16 +++++----- test/DebugInfo/X86/float_const.ll | 6 ++-- test/DebugInfo/X86/float_const_loclist.ll | 6 ++-- test/DebugInfo/X86/formal_parameter.ll | 2 +- test/DebugInfo/X86/ghost-sdnode-dbgvalues.ll | 14 ++++----- test/DebugInfo/X86/inlined-formal-parameter.ll | 6 ++-- test/DebugInfo/X86/live-debug-values.ll | 10 +++--- test/DebugInfo/X86/mi-print.ll | 6 ++-- test/DebugInfo/X86/misched-dbg-value.ll | 16 +++++----- test/DebugInfo/X86/multiple-at-const-val.ll | 2 +- test/DebugInfo/X86/nodebug_with_debug_loc.ll | 6 ++-- test/DebugInfo/X86/nophysreg.ll | 22 ++++++------- test/DebugInfo/X86/partial-constant.ll | 4 +-- test/DebugInfo/X86/pieces-1.ll | 6 ++-- test/DebugInfo/X86/pieces-2.ll | 4 +-- test/DebugInfo/X86/pieces-3.ll | 12 ++++---- test/DebugInfo/X86/pieces-4.ll | 6 ++-- test/DebugInfo/X86/pr28270.ll | 16 +++++----- test/DebugInfo/X86/reference-argument.ll | 4 +-- test/DebugInfo/X86/rematerialize.ll | 12 ++++---- test/DebugInfo/X86/safestack-byval.ll | 4 +-- test/DebugInfo/X86/single-dbg_value.ll | 4 +-- test/DebugInfo/X86/sroasplit-1.ll | 2 +- test/DebugInfo/X86/sroasplit-2.ll | 6 ++-- test/DebugInfo/X86/sroasplit-3.ll | 2 +- test/DebugInfo/X86/sroasplit-4.ll | 8 ++--- test/DebugInfo/X86/stack-value-dwarf2.ll | 6 ++-- test/DebugInfo/X86/stack-value-piece.ll | 10 +++--- test/DebugInfo/X86/subreg.ll | 4 +-- test/DebugInfo/X86/subregisters.ll | 6 ++-- test/DebugInfo/X86/this-stack_value.ll | 10 +++--- test/DebugInfo/X86/union-const.ll | 4 +-- test/Transforms/ADCE/debug-info-intrinsic.ll | 8 ++--- .../pr33641_remove_arg_dbgvalue.ll | 4 +-- test/Transforms/BDCE/dbg-multipleuses.ll | 4 +-- test/Transforms/BDCE/pr26587.ll | 4 +-- test/Transforms/Coroutines/coro-split-dbg.ll | 8 ++--- test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll | 20 ++++++------ test/Transforms/DeadArgElim/dbginfo.ll | 4 +-- .../Transforms/DeadStoreElimination/inst-limits.ll | 4 +-- test/Transforms/GlobalOpt/2009-03-05-dbg.ll | 6 ++-- .../GlobalOpt/localize-constexpr-debuginfo.ll | 8 ++--- test/Transforms/Inline/alloca-dbgdeclare.ll | 4 +-- test/Transforms/Inline/ignore-debug-info.ll | 14 ++++----- .../Inline/local-as-metadata-undominated-use.ll | 4 +-- test/Transforms/InstCombine/debuginfo-dce.ll | 22 ++++++------- test/Transforms/InstCombine/debuginfo-skip.ll | 4 +-- test/Transforms/LICM/debug-value.ll | 4 +-- test/Transforms/LoopIdiom/debug-line.ll | 8 ++--- test/Transforms/LoopReroll/reroll_with_dbg.ll | 12 ++++---- test/Transforms/LoopRotate/dbgvalue.ll | 22 ++++++------- test/Transforms/LoopRotate/phi-dbgvalue.ll | 14 ++++----- test/Transforms/LoopSimplify/dbg-loc.ll | 4 +-- test/Transforms/LoopStrengthReduce/pr12018.ll | 4 +-- test/Transforms/LoopVectorize/dbg.value.ll | 6 ++-- test/Transforms/LoopVectorize/debugloc.ll | 14 ++++----- test/Transforms/Mem2Reg/ConvertDebugInfo.ll | 4 +-- test/Transforms/Mem2Reg/debug-alloca-phi.ll | 4 +-- .../MergeFunc/mergefunc-preserve-debug-info.ll | 4 +-- test/Transforms/ObjCARC/allocas.ll | 2 +- test/Transforms/ObjCARC/basic.ll | 6 ++-- ...ensure-that-exception-unwind-path-is-visited.ll | 10 +++--- test/Transforms/SROA/dbg-single-piece.ll | 2 +- test/Transforms/SafeStack/X86/debug-loc-dynamic.ll | 8 ++--- test/Transforms/SafeStack/X86/debug-loc2.ll | 18 +++++------ test/Transforms/Scalarizer/dbginfo.ll | 14 ++++----- .../SimplifyCFG/PR27615-simplify-cond-br.ll | 6 ++-- test/Transforms/SimplifyCFG/branch-fold-dbg.ll | 4 +-- test/Transforms/SimplifyCFG/hoist-dbgvalue.ll | 10 +++--- test/Transforms/SimplifyCFG/sink-common-code.ll | 4 +-- .../StripSymbols/2010-06-30-StripDebug.ll | 4 +-- .../StripSymbols/strip-dead-debug-info.ll | 4 +-- test/Transforms/Util/simplify-dbg-declare-load.ll | 2 +- test/Transforms/Util/split-bit-piece.ll | 8 ++--- .../Util/strip-nonlinetable-debuginfo-loops.ll | 4 +-- test/Verifier/llvm.dbg.intrinsic-dbg-attachment.ll | 6 ++-- unittests/Transforms/Utils/Cloning.cpp | 3 +- 173 files changed, 713 insertions(+), 680 deletions(-) create mode 100644 test/Bitcode/upgrade-dbg-value.ll create mode 100644 test/Bitcode/upgrade-dbg-value.ll.bc diff --git a/docs/LangRef.rst b/docs/LangRef.rst index 44efc149806..e745567c357 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -4018,7 +4018,7 @@ function is using two metadata arguments: .. code-block:: llvm - call void @llvm.dbg.value(metadata !24, i64 0, metadata !25) + call void @llvm.dbg.value(metadata !24, metadata !25, metadata !26) Metadata can be attached to an instruction. Here metadata ``!21`` is attached to the ``add`` instruction using the ``!dbg`` identifier: diff --git a/docs/SourceLevelDebugging.rst b/docs/SourceLevelDebugging.rst index a9f5c3a0814..ee4c5ce8bce 100644 --- a/docs/SourceLevelDebugging.rst +++ b/docs/SourceLevelDebugging.rst @@ -207,14 +207,13 @@ description of the variable. The third argument is a `complex expression .. code-block:: llvm - void @llvm.dbg.value(metadata, i64, metadata, metadata) + void @llvm.dbg.value(metadata, metadata, metadata) This intrinsic provides information when a user source variable is set to a new -value. The first argument is the new value (wrapped as metadata). The second -argument is the offset in the user source variable where the new value is -written. The third argument is a `local variable -`_ containing a description of the variable. The -fourth argument is a `complex expression `_. +value. The first argument is the new value (wrapped as metadata). The third +argument is a `local variable `_ containing a +description of the variable. The fourth argument is a `complex expression +`_. Object lifetimes and scoping ============================ diff --git a/include/llvm/IR/DIBuilder.h b/include/llvm/IR/DIBuilder.h index 6a14f783005..60f443fe714 100644 --- a/include/llvm/IR/DIBuilder.h +++ b/include/llvm/IR/DIBuilder.h @@ -729,12 +729,11 @@ namespace llvm { /// 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 DL Debug info location. /// \param InsertAtEnd Location for the new intrinsic. - Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, + Instruction *insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, @@ -742,12 +741,11 @@ namespace llvm { /// 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 DL Debug info location. /// \param InsertBefore Location for the new intrinsic. - Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset, + Instruction *insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, diff --git a/include/llvm/IR/IntrinsicInst.h b/include/llvm/IR/IntrinsicInst.h index f55d17ec72c..aad49bc9ac3 100644 --- a/include/llvm/IR/IntrinsicInst.h +++ b/include/llvm/IR/IntrinsicInst.h @@ -122,11 +122,6 @@ namespace llvm { return getVariableLocation(/* AllowNullOp = */ false); } - uint64_t getOffset() const { - return cast( - const_cast(getArgOperand(1)))->getZExtValue(); - } - DILocalVariable *getVariable() const { return cast(getRawVariable()); } @@ -136,11 +131,11 @@ namespace llvm { } Metadata *getRawVariable() const { - return cast(getArgOperand(2))->getMetadata(); + return cast(getArgOperand(1))->getMetadata(); } Metadata *getRawExpression() const { - return cast(getArgOperand(3))->getMetadata(); + return cast(getArgOperand(2))->getMetadata(); } // Methods for support type inquiry through isa, cast, and dyn_cast: diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 14c88e51943..e2cd40b372d 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -579,7 +579,7 @@ let IntrProperties = [IntrNoMem, IntrSpeculatable] in { llvm_metadata_ty, llvm_metadata_ty]>; def int_dbg_value : Intrinsic<[], - [llvm_metadata_ty, llvm_i64_ty, + [llvm_metadata_ty, llvm_metadata_ty, llvm_metadata_ty]>; } diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index ed1bd995e60..9c905848b4e 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -682,10 +682,10 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, if (!V) { // Currently the optimizer can produce this; insert an undef to // help debugging. Probably the optimizer should not do this. - MIRBuilder.buildIndirectDbgValue(0, DI.getOffset(), DI.getVariable(), + MIRBuilder.buildIndirectDbgValue(0, 0, DI.getVariable(), DI.getExpression()); } else if (const auto *CI = dyn_cast(V)) { - MIRBuilder.buildConstDbgValue(*CI, DI.getOffset(), DI.getVariable(), + MIRBuilder.buildConstDbgValue(*CI, 0, DI.getVariable(), DI.getExpression()); } else { unsigned Reg = getOrCreateVReg(*V); @@ -693,12 +693,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID, // direct/indirect thing shouldn't really be handled by something as // implicit as reg+noreg vs reg+imm in the first palce, but it seems // pretty baked in right now. - if (DI.getOffset() != 0) - MIRBuilder.buildIndirectDbgValue(Reg, DI.getOffset(), DI.getVariable(), - DI.getExpression()); - else - MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), - DI.getExpression()); + MIRBuilder.buildDirectDbgValue(Reg, DI.getVariable(), DI.getExpression()); } return true; } diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index b2599b2e17f..57444aa0f48 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -1214,33 +1214,33 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) { // help debugging. Probably the optimizer should not do this. BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II) .addReg(0U) - .addImm(DI->getOffset()) + .addImm(0U) .addMetadata(DI->getVariable()) .addMetadata(DI->getExpression()); } else if (const auto *CI = dyn_cast(V)) { if (CI->getBitWidth() > 64) BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II) .addCImm(CI) - .addImm(DI->getOffset()) + .addImm(0U) .addMetadata(DI->getVariable()) .addMetadata(DI->getExpression()); else BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II) .addImm(CI->getZExtValue()) - .addImm(DI->getOffset()) + .addImm(0U) .addMetadata(DI->getVariable()) .addMetadata(DI->getExpression()); } else if (const auto *CF = dyn_cast(V)) { BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II) .addFPImm(CF) - .addImm(DI->getOffset()) + .addImm(0U) .addMetadata(DI->getVariable()) .addMetadata(DI->getExpression()); } else if (unsigned Reg = lookUpRegForValue(V)) { // FIXME: This does not handle register-indirect values at offset 0. - bool IsIndirect = DI->getOffset() != 0; - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg, - DI->getOffset(), DI->getVariable(), DI->getExpression()); + bool IsIndirect = false; + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg, 0, + DI->getVariable(), DI->getExpression()); } else { // We can't yet handle anything else here because it would require // generating code, thus altering codegen because of debug info. diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 82b0caf0c11..55e01515e1c 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1004,7 +1004,7 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V, DIExpression *Expr = DI->getExpression(); assert(Variable->isValidLocationForIntrinsic(dl) && "Expected inlined-at fields to agree"); - uint64_t Offset = DI->getOffset(); + uint64_t Offset = 0; SDDbgValue *SDV; if (Val.getNode()) { if (!EmitFuncArgumentDbgValue(V, Variable, Expr, dl, Offset, false, @@ -5139,7 +5139,7 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) { DILocalVariable *Variable = DI.getVariable(); DIExpression *Expression = DI.getExpression(); - uint64_t Offset = DI.getOffset(); + uint64_t Offset = 0; const Value *V = DI.getValue(); if (!V) return nullptr; diff --git a/lib/IR/AutoUpgrade.cpp b/lib/IR/AutoUpgrade.cpp index 6a4b8032ffd..16dfd6bd023 100644 --- a/lib/IR/AutoUpgrade.cpp +++ b/lib/IR/AutoUpgrade.cpp @@ -420,6 +420,14 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { } break; } + case 'd': { + if (Name == "dbg.value" && F->arg_size() == 4) { + rename(F); + NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::dbg_value); + return true; + } + break; + } case 'i': case 'l': { bool IsLifetimeStart = Name.startswith("lifetime.start"); @@ -2055,6 +2063,20 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(0)}); break; + case Intrinsic::dbg_value: + // Upgrade from the old version that had an extra offset argument. + assert(CI->getNumArgOperands() == 4); + // Drop nonzero offsets instead of attempting to upgrade them. + if (auto *Offset = dyn_cast_or_null(CI->getArgOperand(1))) + if (Offset->isZeroValue()) { + NewCall = Builder.CreateCall( + NewFn, + {CI->getArgOperand(0), CI->getArgOperand(2), CI->getArgOperand(3)}); + break; + } + CI->eraseFromParent(); + return; + case Intrinsic::x86_xop_vfrcz_ss: case Intrinsic::x86_xop_vfrcz_sd: NewCall = Builder.CreateCall(NewFn, {CI->getArgOperand(1)}); diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index bce28ba3b95..972b6a22324 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -823,7 +823,7 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo, return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL); } -Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, +Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, @@ -840,13 +840,12 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, trackIfUnresolved(VarInfo); trackIfUnresolved(Expr); Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V), - ConstantInt::get(Type::getInt64Ty(VMContext), Offset), MetadataAsValue::get(VMContext, VarInfo), MetadataAsValue::get(VMContext, Expr)}; return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL); } -Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, +Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, DILocalVariable *VarInfo, DIExpression *Expr, const DILocation *DL, @@ -863,7 +862,6 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, trackIfUnresolved(VarInfo); trackIfUnresolved(Expr); Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V), - ConstantInt::get(Type::getInt64Ty(VMContext), Offset), MetadataAsValue::get(VMContext, VarInfo), MetadataAsValue::get(VMContext, Expr)}; diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 805d7155ec7..c3251e26340 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -1073,7 +1073,6 @@ static bool LdStHasDebugValue(DILocalVariable *DIVar, DIExpression *DIExpr, --PrevI; if (DbgValueInst *DVI = dyn_cast(PrevI)) if (DVI->getValue() == I->getOperand(0) && - DVI->getOffset() == 0 && DVI->getVariable() == DIVar && DVI->getExpression() == DIExpr) return true; @@ -1092,7 +1091,6 @@ static bool PhiHasDebugValue(DILocalVariable *DIVar, findDbgValues(DbgValues, APN); for (auto *DVI : DbgValues) { assert(DVI->getValue() == APN); - assert(DVI->getOffset() == 0); if ((DVI->getVariable() == DIVar) && (DVI->getExpression() == DIExpr)) return true; } @@ -1136,7 +1134,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, DV = ExtendedArg; } if (!LdStHasDebugValue(DIVar, DIExpr, SI)) - Builder.insertDbgValueIntrinsic(DV, 0, DIVar, DIExpr, DDI->getDebugLoc(), + Builder.insertDbgValueIntrinsic(DV, DIVar, DIExpr, DDI->getDebugLoc(), SI); } @@ -1156,7 +1154,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, // preferable to keep tracking both the loaded value and the original // address in case the alloca can not be elided. Instruction *DbgValue = Builder.insertDbgValueIntrinsic( - LI, 0, DIVar, DIExpr, DDI->getDebugLoc(), (Instruction *)nullptr); + LI, DIVar, DIExpr, DDI->getDebugLoc(), (Instruction *)nullptr); DbgValue->insertAfter(LI); } @@ -1178,7 +1176,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI, // insertion point. // FIXME: Insert dbg.value markers in the successors when appropriate. if (InsertionPt != BB->end()) - Builder.insertDbgValueIntrinsic(APN, 0, DIVar, DIExpr, DDI->getDebugLoc(), + Builder.insertDbgValueIntrinsic(APN, DIVar, DIExpr, DDI->getDebugLoc(), &*InsertionPt); } @@ -1222,7 +1220,7 @@ bool llvm::LowerDbgDeclare(Function &F) { // This is a call by-value or some other instruction that // takes a pointer to the variable. Insert a *value* // intrinsic that describes the alloca. - DIB.insertDbgValueIntrinsic(AI, 0, DDI->getVariable(), + DIB.insertDbgValueIntrinsic(AI, DDI->getVariable(), DDI->getExpression(), DDI->getDebugLoc(), CI); } @@ -1302,8 +1300,7 @@ static void replaceOneDbgValueForAlloca(DbgValueInst *DVI, Value *NewAddress, DIExpr = Builder.createExpression(Ops); } - Builder.insertDbgValueIntrinsic(NewAddress, DVI->getOffset(), DIVar, DIExpr, - Loc, DVI); + Builder.insertDbgValueIntrinsic(NewAddress, DIVar, DIExpr, Loc, DVI); DVI->eraseFromParent(); } @@ -1351,7 +1348,7 @@ void llvm::salvageDebugInfo(Instruction &I) { Offset.getSExtValue(), DIExpression::WithStackValue); DVI->setOperand(0, MDWrap(I.getOperand(0))); - DVI->setOperand(3, MetadataAsValue::get(I.getContext(), DIExpr)); + DVI->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); DEBUG(dbgs() << "SALVAGE: " << *DVI << '\n'); } } @@ -1363,7 +1360,7 @@ void llvm::salvageDebugInfo(Instruction &I) { DIBuilder DIB(M, /*AllowUnresolved*/ false); DIExpr = DIExpression::prepend(DIExpr, DIExpression::WithDeref); DVI->setOperand(0, MDWrap(I.getOperand(0))); - DVI->setOperand(3, MetadataAsValue::get(I.getContext(), DIExpr)); + DVI->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); DEBUG(dbgs() << "SALVAGE: " << *DVI << '\n'); } } diff --git a/test/Bitcode/upgrade-dbg-value.ll b/test/Bitcode/upgrade-dbg-value.ll new file mode 100644 index 00000000000..5b6ffb6d3e8 --- /dev/null +++ b/test/Bitcode/upgrade-dbg-value.ll @@ -0,0 +1,32 @@ +; Test upgrade of dbg.dvalue intrinsics with offsets. +; +; RUN: llvm-dis < %s.bc | FileCheck %s +; RUN: verify-uselistorder < %s.bc + +define void @f() !dbg !3 { +entry: + ; CHECK-NOT: call void @llvm.dbg.value + ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !9), !dbg !10 + call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !8, metadata !9), !dbg !10 + ; CHECK-NOT: call void @llvm.dbg.value + call void @llvm.dbg.value(metadata i32 0, i64 1, metadata !8, metadata !9), !dbg !10 + ret void +} + +; CHECK: declare void @llvm.dbg.value(metadata, metadata, metadata) +declare void @llvm.dbg.value(metadata, i64, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "llc r309174", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) +!1 = !DIFile(filename: "a.c", directory: "/") +!2 = !{i32 1, !"Debug Info Version", i32 3} +!3 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !4, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, variables: !7) +!4 = !DISubroutineType(types: !5) +!5 = !{!6} +!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!7 = !{!8} +!8 = !DILocalVariable(name: "i", scope: !3, file: !1, line: 2, type: !6) +!9 = !DIExpression() +!10 = !DILocation(line: 2, scope: !3) diff --git a/test/Bitcode/upgrade-dbg-value.ll.bc b/test/Bitcode/upgrade-dbg-value.ll.bc new file mode 100644 index 0000000000000000000000000000000000000000..574a8e4531631985a7ac7c430ab0f27b5b5d681a GIT binary patch literal 1452 zcmZ`(Z)_507=Pht@7m%4mJeW$%UxRyixy7UDvUCLtJ=nXpxI(fmSu$&+8Rm`D7Kmz z=+PWbbf@VDJ{Z$3x@4PMSTxyUTmq#!QmLtPSxDA&ZDhu6XgcGTW$CiLNB4Da;P<}I z^Stl#|2Y?%TYF6nfC>QMl`}+Mla=l*yY`k7EjjqhTdyJZTluasXSbl(IN-9li3#K{RXmX``1U1DTPF)9DldIB$3#!&dx3fQy-r#5dmnPHE5PAkfr+WBM2t6G_Vv~G` z;egtYOzRdrq@OuwyTjR5SnDmM>kikIL~Nx^b!-4V zGlCu%;lmK)d`RF!187W-#{R5>YEQ-acQO8?h7V`>sZ3(u^G*EuI{teOuQG_YI8RjO ziBb($J;V}CEGBeIp8D?v)>>q(nHqjou*|ZS6k?k#7@^UvY1?;*EnAR(Gs=gK^WhK| z9YH4t_^5`D&hgp@Zz`Sx#S1rH5%9+j#Ri2}VHA{Jx0)vxoaDDOv6>)P*NMu8?iUH^ z*YsPm?CV!JTgl!2UmyegsY!G))8F?}P>2~IPmoI<;wi0L%j?ccNYPWYlgFw z3brh3hY8tQ=&G=`6eJ7jyNxhX{uJ~FLr?3`uvp_M3V=Ou_mVvno04m-+IHcR<6f~i z((1<4rmGq)eWWP#x2H@1u-P8qF$@|5fk7&4W~}=UyxQ&aP7G7MLH{^)%omP~jt8Nx zHjHPcLvprP!oi8EwKhb?Es;q2A8C8VJtT9)1jas|hM;Y7FaP&Ct`wLmAc%Q=et6D~0JN#J%|)Pn}{*J)w2mxd0Dg zKa2f}mb$KSwkxneh<%Rhg2fUF;+%LWIOlM0mO1x{tuM}cdmGpdH}D%2h;!d6MvZq% z^YDUyG#DL)yyhgAp@_SmoN%Z?LpudIAdUb%C=Y_6Y+RyIw@62tX`o^ZDzaV$<(;xe zw{tKb^%$5QV5luP^ars&L|hR+0L-8R%OPnE1+eLSyehJkWf2`B6q1tohC}oXbt{+E z9+<-Y+sS-emJ`DOCn*3BxSMcgYf^GiyjolDz^u2y(@tdeZ;=rQ#KsIm-eE(`6PWP% zI}MD186J&xL}I~??J{Ba#jNP872ev_M%oz1WqDI$f cbZ~sgXPgKPhdo2S4rr^RX3G!=)I0*