[llvm] [FMV][GlobalOpt] Statically resolve calls to versioned functions. (PR #87939)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 03:49:31 PST 2025
================
@@ -2642,6 +2642,145 @@ DeleteDeadIFuncs(Module &M,
return Changed;
}
+// Follows the use-def chain of \p V backwards until it finds a Function,
+// in which case it collects in \p Versions.
+static void collectVersions(Value *V, SmallVectorImpl<Function *> &Versions) {
+ if (auto *F = dyn_cast<Function>(V)) {
+ Versions.push_back(F);
+ } else if (auto *Sel = dyn_cast<SelectInst>(V)) {
+ collectVersions(Sel->getTrueValue(), Versions);
+ collectVersions(Sel->getFalseValue(), Versions);
+ } else if (auto *Phi = dyn_cast<PHINode>(V)) {
+ for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I)
+ collectVersions(Phi->getIncomingValue(I), Versions);
+ }
----------------
labrinea wrote:
Ah I see now, to abort earlier. Sounds right, I could do that.
https://github.com/llvm/llvm-project/pull/87939
More information about the llvm-commits
mailing list