@@ -44,10 +44,28 @@ using namespace llvm;
44
44
using namespace llvm ::at;
45
45
using namespace llvm ::dwarf;
46
46
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) {
51
69
// This function is hot. Check whether the value has any metadata to avoid a
52
70
// DenseMap lookup.
53
71
if (!V->isUsedByMetadata ())
@@ -76,7 +94,7 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
76
94
// Get DPValues that use this as a single value.
77
95
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
78
96
for (DPValue *DPV : L->getAllDPValueUsers ()) {
79
- if (Type == DPValue::LocationType::Any || DPV->getType () == Type )
97
+ if (DPV->getType () == DPValue::LocationType::Value )
80
98
DPValues->push_back (DPV);
81
99
}
82
100
}
@@ -90,29 +108,21 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
90
108
continue ;
91
109
DIArgList *DI = cast<DIArgList>(AL);
92
110
for (DPValue *DPV : DI->getAllDPValueUsers ())
93
- if (Type == DPValue::LocationType::Any || DPV->getType () == Type )
111
+ if (DPV->getType () == DPValue::LocationType::Value )
94
112
if (EncounteredDPValues.insert (DPV).second )
95
113
DPValues->push_back (DPV);
96
114
}
97
115
}
98
116
}
99
117
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
-
106
118
void llvm::findDbgValues (SmallVectorImpl<DbgValueInst *> &DbgValues,
107
119
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
108
- findDbgIntrinsics<DbgValueInst, DPValue::LocationType::Value>(DbgValues, V,
109
- DPValues);
120
+ findDbgIntrinsics<DbgValueInst>(DbgValues, V, DPValues);
110
121
}
111
122
112
123
void llvm::findDbgUsers (SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
113
124
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
114
- findDbgIntrinsics<DbgVariableIntrinsic, DPValue::LocationType::Any>(
115
- DbgUsers, V, DPValues);
125
+ findDbgIntrinsics<DbgVariableIntrinsic>(DbgUsers, V, DPValues);
116
126
}
117
127
118
128
DISubprogram *llvm::getDISubprogram (const MDNode *Scope) {
0 commit comments