Skip to content

Commit 958414d

Browse files
PawelJurekpszymich
authored andcommitted
[StackOverflowDetectionDo not add detection calls if no VLA or stackcalls are present in the module.
Adding these calls has performance impact on small kernels. (cherry picked from commit cffcddb)
1 parent b8ab1f2 commit 958414d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

IGC/AdaptorCommon/ProcessFuncAttributes.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,29 @@ bool ProcessFuncAttributes::runOnModule(Module& M)
854854
SetNoInline(F);
855855
}
856856
}
857+
858+
bool HasStackCallsOrVLA =
859+
std::any_of(M.getFunctionList().begin(), M.getFunctionList().end(),
860+
[](auto &F) {
861+
return F.hasFnAttribute("visaStackCall") ||
862+
F.hasFnAttribute("hasVLA");
863+
});
864+
if (!HasStackCallsOrVLA) {
865+
for (auto FuncName : DetectionFunctions) {
866+
if (auto F = M.getFunction(FuncName)) {
867+
std::vector<CallInst *> CallersToDelete;
868+
for (auto User : F->users()) {
869+
if (auto I = dyn_cast<CallInst>(User)) {
870+
CallersToDelete.push_back(I);
871+
}
872+
}
873+
std::for_each(
874+
CallersToDelete.begin(), CallersToDelete.end(),
875+
[](auto CallInst) { CallInst->eraseFromParent(); });
876+
F->eraseFromParent();
877+
}
878+
}
879+
}
857880
}
858881

859882
return true;

0 commit comments

Comments
 (0)