[llvm] [llvm][GlobalOpt] Optimize statically resolvable IFuncs (PR #80606)
Jon Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 09:02:36 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())) {
----------------
jroelofs wrote:
Verifier has:
```
Check(isa<PointerType>(Resolver->getFunctionType()->getReturnType()),
"IFunc resolver must return a pointer", &GI);
```
https://github.com/llvm/llvm-project/pull/80606
More information about the llvm-commits
mailing list