Skip to content

Commit 87c6867

Browse files
committed
Revert "[RemoveDIs][NFC] Find DPValues using findDbgDeclares (#73500)"
This reverts commit 17b8f87. Buildbot: https://lab.llvm.org/buildbot/#/builders/77/builds/32927
1 parent cd138fd commit 87c6867

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

llvm/include/llvm/IR/DebugInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class Module;
4040

4141
/// Finds dbg.declare intrinsics declaring local variables as living in the
4242
/// memory that 'V' points to.
43-
void findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers, Value *V,
44-
SmallVectorImpl<DPValue *> *DPValues = nullptr);
43+
void findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers, Value *V);
4544

4645
/// Finds the llvm.dbg.value intrinsics describing a value.
4746
void findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class DPValue : public ilist_node<DPValue>, private DebugValueUser {
9797
enum class LocationType {
9898
Declare,
9999
Value,
100-
101-
End, ///< Marks the end of the concrete types.
102-
Any, ///< To indicate all LocationTypes in searches.
103100
};
104101
/// Classification of the debug-info record that this DPValue represents.
105102
/// Essentially, "is this a dbg.value or dbg.declare?". dbg.declares are not

llvm/lib/IR/DebugInfo.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,28 @@ using namespace llvm;
4444
using namespace llvm::at;
4545
using namespace llvm::dwarf;
4646

47-
template <typename IntrinsicT,
48-
DPValue::LocationType Type = DPValue::LocationType::Any>
49-
static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
50-
SmallVectorImpl<DPValue *> *DPValues) {
47+
void llvm::findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers,
48+
Value *V) {
49+
// This function is hot. Check whether the value has any metadata to avoid a
50+
// DenseMap lookup.
51+
if (!V->isUsedByMetadata())
52+
return;
53+
auto *L = LocalAsMetadata::getIfExists(V);
54+
if (!L)
55+
return;
56+
auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L);
57+
if (!MDV)
58+
return;
59+
60+
for (User *U : MDV->users()) {
61+
if (auto *DDI = dyn_cast<DbgDeclareInst>(U))
62+
DbgUsers.push_back(DDI);
63+
}
64+
}
65+
66+
template <typename IntrinsicT>
67+
static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result,
68+
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
5169
// This function is hot. Check whether the value has any metadata to avoid a
5270
// DenseMap lookup.
5371
if (!V->isUsedByMetadata())
@@ -76,7 +94,7 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
7694
// Get DPValues that use this as a single value.
7795
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
7896
for (DPValue *DPV : L->getAllDPValueUsers()) {
79-
if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
97+
if (DPV->getType() == DPValue::LocationType::Value)
8098
DPValues->push_back(DPV);
8199
}
82100
}
@@ -90,29 +108,21 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
90108
continue;
91109
DIArgList *DI = cast<DIArgList>(AL);
92110
for (DPValue *DPV : DI->getAllDPValueUsers())
93-
if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
111+
if (DPV->getType() == DPValue::LocationType::Value)
94112
if (EncounteredDPValues.insert(DPV).second)
95113
DPValues->push_back(DPV);
96114
}
97115
}
98116
}
99117

100-
void llvm::findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers,
101-
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
102-
findDbgIntrinsics<DbgDeclareInst, DPValue::LocationType::Declare>(DbgUsers, V,
103-
DPValues);
104-
}
105-
106118
void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues,
107119
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
108-
findDbgIntrinsics<DbgValueInst, DPValue::LocationType::Value>(DbgValues, V,
109-
DPValues);
120+
findDbgIntrinsics<DbgValueInst>(DbgValues, V, DPValues);
110121
}
111122

112123
void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
113124
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
114-
findDbgIntrinsics<DbgVariableIntrinsic, DPValue::LocationType::Any>(
115-
DbgUsers, V, DPValues);
125+
findDbgIntrinsics<DbgVariableIntrinsic>(DbgUsers, V, DPValues);
116126
}
117127

118128
DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {

0 commit comments

Comments
 (0)