Skip to content

Commit c50e671

Browse files
committed
[SWDEV-409372] [AMDGPU] Use removeFnAttrFromReachable in lower-module-lds pass.
Change-Id: Ia7fb46a69fae64acac46dfbcd1608e2038ee04a2
1 parent 1c78b02 commit c50e671

File tree

1 file changed

+1
-43
lines changed

1 file changed

+1
-43
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -864,48 +864,6 @@ class AMDGPULowerModuleLDS {
864864
return N;
865865
}
866866

867-
/// Strip "amdgpu-no-lds-kernel-id" from any functions where we may have
868-
/// introduced its use. If AMDGPUAttributor ran prior to the pass, we inferred
869-
/// the lack of llvm.amdgcn.lds.kernel.id calls.
870-
void removeNoLdsKernelIdFromReachable(CallGraph &CG, Function *KernelRoot) {
871-
KernelRoot->removeFnAttr("amdgpu-no-lds-kernel-id");
872-
873-
SmallVector<Function *> WorkList({CG[KernelRoot]->getFunction()});
874-
SmallPtrSet<Function *, 8> Visited;
875-
bool SeenUnknownCall = false;
876-
877-
while (!WorkList.empty()) {
878-
Function *F = WorkList.pop_back_val();
879-
880-
for (auto &CallRecord : *CG[F]) {
881-
if (!CallRecord.second)
882-
continue;
883-
884-
Function *Callee = CallRecord.second->getFunction();
885-
if (!Callee) {
886-
if (!SeenUnknownCall) {
887-
SeenUnknownCall = true;
888-
889-
// If we see any indirect calls, assume nothing about potential
890-
// targets.
891-
// TODO: This could be refined to possible LDS global users.
892-
for (auto &ExternalCallRecord : *CG.getExternalCallingNode()) {
893-
Function *PotentialCallee =
894-
ExternalCallRecord.second->getFunction();
895-
assert(PotentialCallee);
896-
if (!isKernelLDS(PotentialCallee))
897-
PotentialCallee->removeFnAttr("amdgpu-no-lds-kernel-id");
898-
}
899-
}
900-
} else {
901-
Callee->removeFnAttr("amdgpu-no-lds-kernel-id");
902-
if (Visited.insert(Callee).second)
903-
WorkList.push_back(Callee);
904-
}
905-
}
906-
}
907-
}
908-
909867
DenseMap<Function *, GlobalVariable *> lowerDynamicLDSVariables(
910868
Module &M, LDSUsesInfoTy &LDSUsesInfo,
911869
DenseSet<Function *> const &KernelsThatIndirectlyAllocateDynamicLDS,
@@ -1061,7 +1019,7 @@ class AMDGPULowerModuleLDS {
10611019
//
10621020
// TODO: We could filter out subgraphs that do not access LDS globals.
10631021
for (Function *F : KernelsThatAllocateTableLDS)
1064-
removeNoLdsKernelIdFromReachable(CG, F);
1022+
removeFnAttrFromReachable(CG, F, "amdgpu-no-lds-kernel-id");
10651023
}
10661024

10671025
DenseMap<Function *, GlobalVariable *> KernelToCreatedDynamicLDS =

0 commit comments

Comments
 (0)