Skip to content

Commit 973b1d9

Browse files
committed
[AMDGPU] Update removeFnAttrFromReachable
1 parent b92b555 commit 973b1d9

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -245,43 +245,40 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
245245
StringRef FnAttr) {
246246
KernelRoot->removeFnAttr(FnAttr);
247247

248-
SmallVector<Function *> Tmp({CG[KernelRoot]->getFunction()});
249-
if (!Tmp.back())
250-
return;
251-
248+
SmallVector<Function *> WorkList({CG[KernelRoot]->getFunction()});
252249
SmallPtrSet<Function *, 8> Visited;
253250
bool SeenUnknownCall = false;
254251

255-
do {
256-
Function *F = Tmp.pop_back_val();
252+
while (!WorkList.empty()) {
253+
Function *F = WorkList.pop_back_val();
257254

258-
for (auto &N : *CG[F]) {
259-
if (!N.second)
255+
for (auto &CallRecord : *CG[F]) {
256+
if (!CallRecord.second)
260257
continue;
261258

262-
Function *Callee = N.second->getFunction();
259+
Function *Callee = CallRecord.second->getFunction();
263260
if (!Callee) {
264261
if (!SeenUnknownCall) {
265262
SeenUnknownCall = true;
266263

267264
// If we see any indirect calls, assume nothing about potential
268265
// targets.
269266
// 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);
272271
if (!isKernelLDS(PotentialCallee))
273272
PotentialCallee->removeFnAttr(FnAttr);
274273
}
275-
276-
continue;
277274
}
275+
} else {
276+
Callee->removeFnAttr(FnAttr);
277+
if (Visited.insert(Callee).second)
278+
WorkList.push_back(Callee);
278279
}
279-
280-
Callee->removeFnAttr(FnAttr);
281-
if (Visited.insert(Callee).second)
282-
Tmp.push_back(Callee);
283280
}
284-
} while (!Tmp.empty());
281+
}
285282
}
286283

287284
bool isReallyAClobber(const Value *Ptr, MemoryDef *Def, AAResults *AA) {

0 commit comments

Comments
 (0)