@@ -1034,43 +1034,40 @@ class AMDGPULowerModuleLDS {
1034
1034
void removeNoLdsKernelIdFromReachable (CallGraph &CG, Function *KernelRoot) {
1035
1035
KernelRoot->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1036
1036
1037
- SmallVector<Function *> Tmp ({CG[KernelRoot]->getFunction ()});
1038
- if (!Tmp.back ())
1039
- return ;
1040
-
1037
+ SmallVector<Function *> WorkList ({CG[KernelRoot]->getFunction ()});
1041
1038
SmallPtrSet<Function *, 8 > Visited;
1042
1039
bool SeenUnknownCall = false ;
1043
1040
1044
- do {
1045
- Function *F = Tmp .pop_back_val ();
1041
+ while (!WorkList. empty ()) {
1042
+ Function *F = WorkList .pop_back_val ();
1046
1043
1047
- for (auto &N : *CG[F]) {
1048
- if (!N .second )
1044
+ for (auto &CallRecord : *CG[F]) {
1045
+ if (!CallRecord .second )
1049
1046
continue ;
1050
1047
1051
- Function *Callee = N .second ->getFunction ();
1048
+ Function *Callee = CallRecord .second ->getFunction ();
1052
1049
if (!Callee) {
1053
1050
if (!SeenUnknownCall) {
1054
1051
SeenUnknownCall = true ;
1055
1052
1056
1053
// If we see any indirect calls, assume nothing about potential
1057
1054
// targets.
1058
1055
// TODO: This could be refined to possible LDS global users.
1059
- for (auto &N : *CG.getExternalCallingNode ()) {
1060
- Function *PotentialCallee = N.second ->getFunction ();
1056
+ for (auto &ExternalCallRecord : *CG.getExternalCallingNode ()) {
1057
+ Function *PotentialCallee =
1058
+ ExternalCallRecord.second ->getFunction ();
1059
+ assert (PotentialCallee);
1061
1060
if (!isKernelLDS (PotentialCallee))
1062
1061
PotentialCallee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1063
1062
}
1064
-
1065
- continue ;
1066
1063
}
1064
+ } else {
1065
+ Callee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1066
+ if (Visited.insert (Callee).second )
1067
+ WorkList.push_back (Callee);
1067
1068
}
1068
-
1069
- Callee->removeFnAttr (" amdgpu-no-lds-kernel-id" );
1070
- if (Visited.insert (Callee).second )
1071
- Tmp.push_back (Callee);
1072
1069
}
1073
- } while (!Tmp. empty ());
1070
+ }
1074
1071
}
1075
1072
1076
1073
DenseMap<Function *, GlobalVariable *> lowerDynamicLDSVariables (
0 commit comments