Skip to content

Commit 7573d5e

Browse files
authored
[AMDGPU] Update removeFnAttrFromReachable to accept array of Fn Attrs. (#94188)
This PR updates removeFnAttrFromReachable in AMDGPUMemoryUtils to accept array of function attributes as argument. Helps to remove multiple attributes in one CallGraph walk.
1 parent f882f8c commit 7573d5e

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ class AMDGPULowerModuleLDS {
10171017
//
10181018
// TODO: We could filter out subgraphs that do not access LDS globals.
10191019
for (Function *F : KernelsThatAllocateTableLDS)
1020-
removeFnAttrFromReachable(CG, F, "amdgpu-no-lds-kernel-id");
1020+
removeFnAttrFromReachable(CG, F, {"amdgpu-no-lds-kernel-id"});
10211021
}
10221022

10231023
DenseMap<Function *, GlobalVariable *> KernelToCreatedDynamicLDS =

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
235235
}
236236

237237
void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
238-
StringRef FnAttr) {
239-
KernelRoot->removeFnAttr(FnAttr);
238+
ArrayRef<StringRef> FnAttrs) {
239+
for (StringRef Attr : FnAttrs)
240+
KernelRoot->removeFnAttr(Attr);
240241

241242
SmallVector<Function *> WorkList = {CG[KernelRoot]->getFunction()};
242243
SmallPtrSet<Function *, 8> Visited;
@@ -261,12 +262,15 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
261262
Function *PotentialCallee =
262263
ExternalCallRecord.second->getFunction();
263264
assert(PotentialCallee);
264-
if (!isKernelLDS(PotentialCallee))
265-
PotentialCallee->removeFnAttr(FnAttr);
265+
if (!isKernelLDS(PotentialCallee)) {
266+
for (StringRef Attr : FnAttrs)
267+
PotentialCallee->removeFnAttr(Attr);
268+
}
266269
}
267270
}
268271
} else {
269-
Callee->removeFnAttr(FnAttr);
272+
for (StringRef Attr : FnAttrs)
273+
Callee->removeFnAttr(Attr);
270274
if (Visited.insert(Callee).second)
271275
WorkList.push_back(Callee);
272276
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
1010
#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
1111

12+
#include "llvm/ADT/ArrayRef.h"
1213
#include "llvm/ADT/DenseMap.h"
1314
#include "llvm/ADT/DenseSet.h"
1415

@@ -54,7 +55,7 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M);
5455
/// Strip FnAttr attribute from any functions where we may have
5556
/// introduced its use.
5657
void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
57-
StringRef FnAttr);
58+
ArrayRef<StringRef> FnAttrs);
5859

5960
/// Given a \p Def clobbering a load from \p Ptr according to the MSSA check
6061
/// if this is actually a memory update or an artificial clobber to facilitate

0 commit comments

Comments
 (0)