@@ -45,25 +45,6 @@ using namespace llvm;
45
45
using namespace llvm ::at;
46
46
using namespace llvm ::dwarf;
47
47
48
- TinyPtrVector<DbgDeclareInst *> llvm::findDbgDeclares (Value *V) {
49
- // This function is hot. Check whether the value has any metadata to avoid a
50
- // DenseMap lookup. This check is a bitfield datamember lookup.
51
- if (!V->isUsedByMetadata ())
52
- return {};
53
- auto *L = ValueAsMetadata::getIfExists (V);
54
- if (!L)
55
- return {};
56
- auto *MDV = MetadataAsValue::getIfExists (V->getContext (), L);
57
- if (!MDV)
58
- return {};
59
-
60
- TinyPtrVector<DbgDeclareInst *> Declares;
61
- for (User *U : MDV->users ())
62
- if (auto *DDI = dyn_cast<DbgDeclareInst>(U))
63
- Declares.push_back (DDI);
64
-
65
- return Declares;
66
- }
67
48
TinyPtrVector<DbgVariableRecord *> llvm::findDVRDeclares (Value *V) {
68
49
// This function is hot. Check whether the value has any metadata to avoid a
69
50
// DenseMap lookup. This check is a bitfield datamember lookup.
@@ -98,42 +79,31 @@ TinyPtrVector<DbgVariableRecord *> llvm::findDVRValues(Value *V) {
98
79
return Values;
99
80
}
100
81
101
- template <typename IntrinsicT, bool DbgAssignAndValuesOnly>
82
+ template <bool DbgAssignAndValuesOnly>
102
83
static void
103
- findDbgIntrinsics (SmallVectorImpl<IntrinsicT *> &Result, Value *V,
104
- SmallVectorImpl<DbgVariableRecord *> * DbgVariableRecords) {
84
+ findDbgIntrinsics (Value *V,
85
+ SmallVectorImpl<DbgVariableRecord *> & DbgVariableRecords) {
105
86
// This function is hot. Check whether the value has any metadata to avoid a
106
87
// DenseMap lookup.
107
88
if (!V->isUsedByMetadata ())
108
89
return ;
109
90
110
- LLVMContext &Ctx = V->getContext ();
111
91
// TODO: If this value appears multiple times in a DIArgList, we should still
112
- // only add the owning DbgValueInst once; use this set to track ArgListUsers.
92
+ // only add the owning dbg.value once; use this set to track ArgListUsers.
113
93
// This behaviour can be removed when we can automatically remove duplicates.
114
94
// V will also appear twice in a dbg.assign if its used in the both the value
115
95
// and address components.
116
- SmallPtrSet<IntrinsicT *, 4 > EncounteredIntrinsics;
117
96
SmallPtrSet<DbgVariableRecord *, 4 > EncounteredDbgVariableRecords;
118
97
119
- // / Append IntrinsicT users of MetadataAsValue(MD).
120
- auto AppendUsers = [&Ctx, &EncounteredIntrinsics,
121
- &EncounteredDbgVariableRecords, &Result,
122
- DbgVariableRecords](Metadata *MD) {
123
- if (auto *MDV = MetadataAsValue::getIfExists (Ctx, MD)) {
124
- for (User *U : MDV->users ())
125
- if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U))
126
- if (EncounteredIntrinsics.insert (DVI).second )
127
- Result.push_back (DVI);
128
- }
129
- if (!DbgVariableRecords)
130
- return ;
98
+ // / Append users of MetadataAsValue(MD).
99
+ auto AppendUsers = [&EncounteredDbgVariableRecords,
100
+ &DbgVariableRecords](Metadata *MD) {
131
101
// Get DbgVariableRecords that use this as a single value.
132
102
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
133
103
for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers ()) {
134
104
if (!DbgAssignAndValuesOnly || DVR->isDbgValue () || DVR->isDbgAssign ())
135
105
if (EncounteredDbgVariableRecords.insert (DVR).second )
136
- DbgVariableRecords-> push_back (DVR);
106
+ DbgVariableRecords. push_back (DVR);
137
107
}
138
108
}
139
109
};
@@ -142,29 +112,23 @@ findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
142
112
AppendUsers (L);
143
113
for (Metadata *AL : L->getAllArgListUsers ()) {
144
114
AppendUsers (AL);
145
- if (!DbgVariableRecords)
146
- continue ;
147
115
DIArgList *DI = cast<DIArgList>(AL);
148
116
for (DbgVariableRecord *DVR : DI->getAllDbgVariableRecordUsers ())
149
117
if (!DbgAssignAndValuesOnly || DVR->isDbgValue () || DVR->isDbgAssign ())
150
118
if (EncounteredDbgVariableRecords.insert (DVR).second )
151
- DbgVariableRecords-> push_back (DVR);
119
+ DbgVariableRecords. push_back (DVR);
152
120
}
153
121
}
154
122
}
155
123
156
124
void llvm::findDbgValues (
157
- SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V,
158
- SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
159
- findDbgIntrinsics<DbgValueInst, /* DbgAssignAndValuesOnly=*/ true >(
160
- DbgValues, V, DbgVariableRecords);
125
+ Value *V, SmallVectorImpl<DbgVariableRecord *> &DbgVariableRecords) {
126
+ findDbgIntrinsics</* DbgAssignAndValuesOnly=*/ true >(V, DbgVariableRecords);
161
127
}
162
128
163
129
void llvm::findDbgUsers (
164
- SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers, Value *V,
165
- SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
166
- findDbgIntrinsics<DbgVariableIntrinsic, /* DbgAssignAndValuesOnly=*/ false >(
167
- DbgUsers, V, DbgVariableRecords);
130
+ Value *V, SmallVectorImpl<DbgVariableRecord *> &DbgVariableRecords) {
131
+ findDbgIntrinsics</* DbgAssignAndValuesOnly=*/ false >(V, DbgVariableRecords);
168
132
}
169
133
170
134
DISubprogram *llvm::getDISubprogram (const MDNode *Scope) {
@@ -173,18 +137,6 @@ DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {
173
137
return nullptr ;
174
138
}
175
139
176
- DebugLoc llvm::getDebugValueLoc (DbgVariableIntrinsic *DII) {
177
- // Original dbg.declare must have a location.
178
- const DebugLoc &DeclareLoc = DII->getDebugLoc ();
179
- MDNode *Scope = DeclareLoc.getScope ();
180
- DILocation *InlinedAt = DeclareLoc.getInlinedAt ();
181
- // Because no machine insts can come from debug intrinsics, only the scope
182
- // and inlinedAt is significant. Zero line numbers are used in case this
183
- // DebugLoc leaks into any adjacent instructions. Produce an unknown location
184
- // with the correct scope / inlinedAt fields.
185
- return DILocation::get (DII->getContext (), 0 , 0 , Scope, InlinedAt);
186
- }
187
-
188
140
DebugLoc llvm::getDebugValueLoc (DbgVariableRecord *DVR) {
189
141
// Original dbg.declare must have a location.
190
142
const DebugLoc &DeclareLoc = DVR->getDebugLoc ();
@@ -852,19 +804,6 @@ void DebugTypeInfoRemoval::traverse(MDNode *N) {
852
804
bool llvm::stripNonLineTableDebugInfo (Module &M) {
853
805
bool Changed = false ;
854
806
855
- // First off, delete the debug intrinsics.
856
- auto RemoveUses = [&](StringRef Name) {
857
- if (auto *DbgVal = M.getFunction (Name)) {
858
- while (!DbgVal->use_empty ())
859
- cast<Instruction>(DbgVal->user_back ())->eraseFromParent ();
860
- DbgVal->eraseFromParent ();
861
- Changed = true ;
862
- }
863
- };
864
- RemoveUses (" llvm.dbg.declare" );
865
- RemoveUses (" llvm.dbg.label" );
866
- RemoveUses (" llvm.dbg.value" );
867
-
868
807
// Delete non-CU debug info named metadata nodes.
869
808
for (auto NMI = M.named_metadata_begin (), NME = M.named_metadata_end ();
870
809
NMI != NME;) {
0 commit comments