[llvm] [llvm][GlobalOpt] Optimize statically resolvable IFuncs (PR #80606)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 05:30:23 PST 2024
================
@@ -2404,6 +2405,42 @@ static bool OptimizeEmptyGlobalCXXDtors(Function *CXAAtExitFn) {
return Changed;
}
+static Function *hasSideeffectFreeStaticResolution(GlobalIFunc &IF) {
+ Function *Resolver = IF.getResolverFunction();
+ if (!Resolver)
+ return nullptr;
+
+ Function *Callee = nullptr;
+ for (BasicBlock &BB : *Resolver) {
+ if (any_of(BB, [](Instruction &I) { return I.mayHaveSideEffects(); }))
+ return nullptr;
+
+ if (auto *Ret = dyn_cast<ReturnInst>(BB.getTerminator()))
+ if (auto *F = dyn_cast<Function>(Ret->getReturnValue())) {
----------------
nikic wrote:
Can an ifunc resolver return void (without failing the verifier or something)? If so, this will probably crash.
https://github.com/llvm/llvm-project/pull/80606
More information about the llvm-commits
mailing list