@@ -1052,43 +1052,40 @@ class AMDGPULowerModuleLDS {
1052
1052
void removeNoLdsKernelIdFromReachable (CallGraph &CG, Function *KernelRoot) {
1053
1053
KernelRoot->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1054
1054
1055
- SmallVector<Function *> Tmp ({CG[KernelRoot]->getFunction ()});
1056
- if (!Tmp.back ())
1057
- return ;
1058
-
1055
+ SmallVector<Function *> WorkList ({CG[KernelRoot]->getFunction ()});
1059
1056
SmallPtrSet<Function *, 8 > Visited;
1060
1057
bool SeenUnknownCall = false ;
1061
1058
1062
- do {
1063
- Function *F = Tmp .pop_back_val ();
1059
+ while (!WorkList. empty ()) {
1060
+ Function *F = WorkList .pop_back_val ();
1064
1061
1065
- for (auto &N : *CG[F]) {
1066
- if (!N .second )
1062
+ for (auto &CallRecord : *CG[F]) {
1063
+ if (!CallRecord .second )
1067
1064
continue ;
1068
1065
1069
- Function *Callee = N .second ->getFunction ();
1066
+ Function *Callee = CallRecord .second ->getFunction ();
1070
1067
if (!Callee) {
1071
1068
if (!SeenUnknownCall) {
1072
1069
SeenUnknownCall = true ;
1073
1070
1074
1071
// If we see any indirect calls, assume nothing about potential
1075
1072
// targets.
1076
1073
// TODO: This could be refined to possible LDS global users.
1077
- for (auto &N : *CG.getExternalCallingNode ()) {
1078
- Function *PotentialCallee = N.second ->getFunction ();
1074
+ for (auto &ExternalCallRecord : *CG.getExternalCallingNode ()) {
1075
+ Function *PotentialCallee =
1076
+ ExternalCallRecord.second ->getFunction ();
1077
+ assert (PotentialCallee);
1079
1078
if (!isKernelLDS (PotentialCallee))
1080
1079
PotentialCallee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1081
1080
}
1082
-
1083
- continue ;
1084
1081
}
1082
+ } else {
1083
+ Callee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1084
+ if (Visited.insert (Callee).second )
1085
+ WorkList.push_back (Callee);
1085
1086
}
1086
-
1087
- Callee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1088
- if (Visited.insert (Callee).second )
1089
- Tmp.push_back (Callee);
1090
1087
}
1091
- } while (!Tmp. empty ());
1088
+ }
1092
1089
}
1093
1090
1094
1091
DenseMap<Function *, GlobalVariable *> lowerDynamicLDSVariables (
0 commit comments