Skip to content

[AMDGPU] Update removeFnAttrFromReachable to accept array of Fn Attrs. #94188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ class AMDGPULowerModuleLDS {
//
// TODO: We could filter out subgraphs that do not access LDS globals.
for (Function *F : KernelsThatAllocateTableLDS)
removeFnAttrFromReachable(CG, F, "amdgpu-no-lds-kernel-id");
removeFnAttrFromReachable(CG, F, {"amdgpu-no-lds-kernel-id"});
}

DenseMap<Function *, GlobalVariable *> KernelToCreatedDynamicLDS =
Expand Down
14 changes: 9 additions & 5 deletions llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
}

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

SmallVector<Function *> WorkList = {CG[KernelRoot]->getFunction()};
SmallPtrSet<Function *, 8> Visited;
Expand All @@ -261,12 +262,15 @@ void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot,
Function *PotentialCallee =
ExternalCallRecord.second->getFunction();
assert(PotentialCallee);
if (!isKernelLDS(PotentialCallee))
PotentialCallee->removeFnAttr(FnAttr);
if (!isKernelLDS(PotentialCallee)) {
for (StringRef Attr : FnAttrs)
PotentialCallee->removeFnAttr(Attr);
}
}
}
} else {
Callee->removeFnAttr(FnAttr);
for (StringRef Attr : FnAttrs)
Callee->removeFnAttr(Attr);
if (Visited.insert(Callee).second)
WorkList.push_back(Callee);
}
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H
#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"

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

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