From fd16ff3a7ef7c03932066ed992a672d7e8abd304 Mon Sep 17 00:00:00 2001 From: OCHyams Date: Mon, 7 Nov 2022 15:12:18 +0000 Subject: [PATCH] Reapply: [NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h Reverted in b22d80dc6a6af6328d68f7b944627f9278ff6ffb. Move getDebugValueLoc so that it can be accessed from DebugInfo.h for the Assignment Tracking patch stack and remove redundant parameter Src. Reviewed By: jryans Differential Revision: https://reviews.llvm.org/D132357 --- llvm/include/llvm/IR/DebugInfo.h | 4 ++++ llvm/lib/IR/DebugInfo.cpp | 12 ++++++++++++ llvm/lib/Transforms/Utils/Local.cpp | 21 ++++----------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/IR/DebugInfo.h b/llvm/include/llvm/IR/DebugInfo.h index 16b7aa3..ab6a369 100644 --- a/llvm/include/llvm/IR/DebugInfo.h +++ b/llvm/include/llvm/IR/DebugInfo.h @@ -49,6 +49,10 @@ void findDbgUsers(SmallVectorImpl &DbgInsts, Value *V); /// Find subprogram that is enclosing this scope. DISubprogram *getDISubprogram(const MDNode *Scope); +/// Produce a DebugLoc to use for each dbg.declare that is promoted to a +/// dbg.value. +DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII); + /// Strip debug info in the module if it exists. /// /// To do this, we remove all calls to the debugger intrinsics and any named diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index a051a1b..64d606e 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -140,6 +140,18 @@ DISubprogram *llvm::getDISubprogram(const MDNode *Scope) { return nullptr; } +DebugLoc llvm::getDebugValueLoc(DbgVariableIntrinsic *DII) { + // Original dbg.declare must have a location. + const DebugLoc &DeclareLoc = DII->getDebugLoc(); + MDNode *Scope = DeclareLoc.getScope(); + DILocation *InlinedAt = DeclareLoc.getInlinedAt(); + // Because no machine insts can come from debug intrinsics, only the scope + // and inlinedAt is significant. Zero line numbers are used in case this + // DebugLoc leaks into any adjacent instructions. Produce an unknown location + // with the correct scope / inlinedAt fields. + return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt); +} + //===----------------------------------------------------------------------===// // DebugInfoFinder implementations. //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index e6b3b5c..e31e691 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1495,19 +1495,6 @@ static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) { return false; } -/// Produce a DebugLoc to use for each dbg.declare/inst pair that are promoted -/// to a dbg.value. Because no machine insts can come from debug intrinsics, -/// only the scope and inlinedAt is significant. Zero line numbers are used in -/// case this DebugLoc leaks into any adjacent instructions. -static DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII, Instruction *Src) { - // Original dbg.declare must have a location. - const DebugLoc &DeclareLoc = DII->getDebugLoc(); - MDNode *Scope = DeclareLoc.getScope(); - DILocation *InlinedAt = DeclareLoc.getInlinedAt(); - // Produce an unknown location with the correct scope / inlinedAt fields. - return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt); -} - /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, @@ -1518,7 +1505,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, auto *DIExpr = DII->getExpression(); Value *DV = SI->getValueOperand(); - DebugLoc NewLoc = getDebugValueLoc(DII, SI); + DebugLoc NewLoc = getDebugValueLoc(DII); if (!valueCoversEntireFragment(DV->getType(), DII)) { // FIXME: If storing to a part of the variable described by the dbg.declare, @@ -1553,7 +1540,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, return; } - DebugLoc NewLoc = getDebugValueLoc(DII, nullptr); + DebugLoc NewLoc = getDebugValueLoc(DII); // We are now tracking the loaded value instead of the address. In the // future if multi-location support is added to the IR, it might be @@ -1587,7 +1574,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, BasicBlock *BB = APN->getParent(); auto InsertionPt = BB->getFirstInsertionPt(); - DebugLoc NewLoc = getDebugValueLoc(DII, nullptr); + DebugLoc NewLoc = getDebugValueLoc(DII); // The block may be a catchswitch block, which does not have a valid // insertion point. @@ -1659,7 +1646,7 @@ bool llvm::LowerDbgDeclare(Function &F) { // pointer to the variable. Insert a *value* intrinsic that describes // the variable by dereferencing the alloca. if (!CI->isLifetimeStartOrEnd()) { - DebugLoc NewLoc = getDebugValueLoc(DDI, nullptr); + DebugLoc NewLoc = getDebugValueLoc(DDI); auto *DerefExpr = DIExpression::append(DDI->getExpression(), dwarf::DW_OP_deref); DIB.insertDbgValueIntrinsic(AI, DDI->getVariable(), DerefExpr, -- 2.7.4