Skip to content

Commit fd16ff3

Browse files
committed
Reapply: [NFC] Move getDebugValueLoc from static in Local.cpp to DebugInfo.h
Reverted in b22d80d. 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
1 parent a5c18fc commit fd16ff3

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

llvm/include/llvm/IR/DebugInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgInsts, Value *V);
4949
/// Find subprogram that is enclosing this scope.
5050
DISubprogram *getDISubprogram(const MDNode *Scope);
5151

52+
/// Produce a DebugLoc to use for each dbg.declare that is promoted to a
53+
/// dbg.value.
54+
DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII);
55+
5256
/// Strip debug info in the module if it exists.
5357
///
5458
/// To do this, we remove all calls to the debugger intrinsics and any named

llvm/lib/IR/DebugInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,18 @@ DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
140140
return nullptr;
141141
}
142142

143+
DebugLoc llvm::getDebugValueLoc(DbgVariableIntrinsic *DII) {
144+
// Original dbg.declare must have a location.
145+
const DebugLoc &DeclareLoc = DII->getDebugLoc();
146+
MDNode *Scope = DeclareLoc.getScope();
147+
DILocation *InlinedAt = DeclareLoc.getInlinedAt();
148+
// Because no machine insts can come from debug intrinsics, only the scope
149+
// and inlinedAt is significant. Zero line numbers are used in case this
150+
// DebugLoc leaks into any adjacent instructions. Produce an unknown location
151+
// with the correct scope / inlinedAt fields.
152+
return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt);
153+
}
154+
143155
//===----------------------------------------------------------------------===//
144156
// DebugInfoFinder implementations.
145157
//===----------------------------------------------------------------------===//

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,19 +1495,6 @@ static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
14951495
return false;
14961496
}
14971497

1498-
/// Produce a DebugLoc to use for each dbg.declare/inst pair that are promoted
1499-
/// to a dbg.value. Because no machine insts can come from debug intrinsics,
1500-
/// only the scope and inlinedAt is significant. Zero line numbers are used in
1501-
/// case this DebugLoc leaks into any adjacent instructions.
1502-
static DebugLoc getDebugValueLoc(DbgVariableIntrinsic *DII, Instruction *Src) {
1503-
// Original dbg.declare must have a location.
1504-
const DebugLoc &DeclareLoc = DII->getDebugLoc();
1505-
MDNode *Scope = DeclareLoc.getScope();
1506-
DILocation *InlinedAt = DeclareLoc.getInlinedAt();
1507-
// Produce an unknown location with the correct scope / inlinedAt fields.
1508-
return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt);
1509-
}
1510-
15111498
/// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value
15121499
/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic.
15131500
void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
@@ -1518,7 +1505,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
15181505
auto *DIExpr = DII->getExpression();
15191506
Value *DV = SI->getValueOperand();
15201507

1521-
DebugLoc NewLoc = getDebugValueLoc(DII, SI);
1508+
DebugLoc NewLoc = getDebugValueLoc(DII);
15221509

15231510
if (!valueCoversEntireFragment(DV->getType(), DII)) {
15241511
// FIXME: If storing to a part of the variable described by the dbg.declare,
@@ -1553,7 +1540,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
15531540
return;
15541541
}
15551542

1556-
DebugLoc NewLoc = getDebugValueLoc(DII, nullptr);
1543+
DebugLoc NewLoc = getDebugValueLoc(DII);
15571544

15581545
// We are now tracking the loaded value instead of the address. In the
15591546
// future if multi-location support is added to the IR, it might be
@@ -1587,7 +1574,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII,
15871574
BasicBlock *BB = APN->getParent();
15881575
auto InsertionPt = BB->getFirstInsertionPt();
15891576

1590-
DebugLoc NewLoc = getDebugValueLoc(DII, nullptr);
1577+
DebugLoc NewLoc = getDebugValueLoc(DII);
15911578

15921579
// The block may be a catchswitch block, which does not have a valid
15931580
// insertion point.
@@ -1659,7 +1646,7 @@ bool llvm::LowerDbgDeclare(Function &F) {
16591646
// pointer to the variable. Insert a *value* intrinsic that describes
16601647
// the variable by dereferencing the alloca.
16611648
if (!CI->isLifetimeStartOrEnd()) {
1662-
DebugLoc NewLoc = getDebugValueLoc(DDI, nullptr);
1649+
DebugLoc NewLoc = getDebugValueLoc(DDI);
16631650
auto *DerefExpr =
16641651
DIExpression::append(DDI->getExpression(), dwarf::DW_OP_deref);
16651652
DIB.insertDbgValueIntrinsic(AI, DDI->getVariable(), DerefExpr,

0 commit comments

Comments
 (0)