[llvm] [llvm][GlobalOpt] Optimize statically resolvable IFuncs (PR #80606)

Alexandros Lamprineas via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 13:58:33 PDT 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) {
----------------
labrinea wrote:

I have tried a few things to achieve what @jroelofs is describing but none of them seems ideal:
* extend IPSCCP to create specializations of the resolver
* constant fold the resolver per callsite in InstCombineCalls.cpp
The second attempt looks better but I am not sure Instcombine allows such expensive transformations. Another concern is that when constant folding I am handing a few types of instructions which I know the FMV resolver on AArch64 will have. That's quite specific - not generic enough. Also having to use the AArch64 Target Parser to create a constant mask, or looking for loads from address __aarch64_cpu_features doesn't fit well in a target independent optimization. Thoughts?

https://github.com/llvm/llvm-project/pull/80606


More information about the llvm-commits mailing list