[llvm] [DevirtSCC] Repeat inline while ind call is replaced by a non-call value (PR #174400)
Kunqiu Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 16 08:18:06 PST 2026
https://github.com/Camsyn updated https://github.com/llvm/llvm-project/pull/174400
>From 3bd40742912e191f1ee8d4a625ba976faad691de Mon Sep 17 00:00:00 2001
From: Camsyn <camsyn at foxmail.com>
Date: Mon, 5 Jan 2026 20:36:11 +0800
Subject: [PATCH] Repeat inline while ind call is replaced by a non-call value
---
llvm/lib/Analysis/CGSCCPassManager.cpp | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 81c9604fe8098..3f231a9ca2cae 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/PassManagerImpl.h"
@@ -450,6 +451,19 @@ PreservedAnalyses DevirtSCCRepeatedPass::run(LazyCallGraph::SCC &InitialC,
LLVM_DEBUG(dbgs() << "Found devirtualized call: " << *CB << "\n");
return true;
}
+ } else if (!isa<PoisonValue>(P.second)) {
+ // If a return value of a indirect call is replaced by some non-call
+ // value, it means one of the following TWO cases happens:
+ // 1. The indirect call is replaced by a direct call, and thus we can
+ // infer the return value straighforwardly through the callee.
+ // -->
+ // Devirtualization happened.
+ // 2. The indirect call is unreachable, and thus is replaced by
+ // `poison`
+ // -->
+ // Devirtualization did not happen.
+ LLVM_DEBUG(dbgs() << "Found ind call -> non-call value: " << *P.second << "\n");
+ return true;
}
}
return false;
More information about the llvm-commits
mailing list