@@ -245,43 +245,40 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
245
245
StringRef FnAttr) {
246
246
KernelRoot->removeFnAttr (FnAttr);
247
247
248
- SmallVector<Function *> Tmp ({CG[KernelRoot]->getFunction ()});
249
- if (!Tmp.back ())
250
- return ;
251
-
248
+ SmallVector<Function *> WorkList ({CG[KernelRoot]->getFunction ()});
252
249
SmallPtrSet<Function *, 8 > Visited;
253
250
bool SeenUnknownCall = false ;
254
251
255
- do {
256
- Function *F = Tmp .pop_back_val ();
252
+ while (!WorkList. empty ()) {
253
+ Function *F = WorkList .pop_back_val ();
257
254
258
- for (auto &N : *CG[F]) {
259
- if (!N .second )
255
+ for (auto &CallRecord : *CG[F]) {
256
+ if (!CallRecord .second )
260
257
continue ;
261
258
262
- Function *Callee = N .second ->getFunction ();
259
+ Function *Callee = CallRecord .second ->getFunction ();
263
260
if (!Callee) {
264
261
if (!SeenUnknownCall) {
265
262
SeenUnknownCall = true ;
266
263
267
264
// If we see any indirect calls, assume nothing about potential
268
265
// targets.
269
266
// TODO: This could be refined to possible LDS global users.
270
- for (auto &N : *CG.getExternalCallingNode ()) {
271
- Function *PotentialCallee = N.second ->getFunction ();
267
+ for (auto &ExternalCallRecord : *CG.getExternalCallingNode ()) {
268
+ Function *PotentialCallee =
269
+ ExternalCallRecord.second ->getFunction ();
270
+ assert (PotentialCallee);
272
271
if (!isKernelLDS (PotentialCallee))
273
272
PotentialCallee->removeFnAttr (FnAttr);
274
273
}
275
-
276
- continue ;
277
274
}
275
+ } else {
276
+ Callee->removeFnAttr (FnAttr);
277
+ if (Visited.insert (Callee).second )
278
+ WorkList.push_back (Callee);
278
279
}
279
-
280
- Callee->removeFnAttr (FnAttr);
281
- if (Visited.insert (Callee).second )
282
- Tmp.push_back (Callee);
283
280
}
284
- } while (!Tmp. empty ());
281
+ }
285
282
}
286
283
287
284
bool isReallyAClobber (const Value *Ptr, MemoryDef *Def, AAResults *AA) {
0 commit comments