aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-04-12 11:03:42 +0200
committerNikita Popov <npopov@redhat.com>2022-04-12 11:05:33 +0200
commit8d5c8d57c637d898094af323d1888ea5a3364f8c (patch)
tree57342b72a11a6f5a2fad12aa744f13965c21139d /llvm/lib/Analysis/InlineCost.cpp
parentdbd80d7d27866a6ca709e032394985a3cb0fcadf (diff)
downloadllvm-8d5c8d57c637d898094af323d1888ea5a3364f8c.zip
llvm-8d5c8d57c637d898094af323d1888ea5a3364f8c.tar.gz
llvm-8d5c8d57c637d898094af323d1888ea5a3364f8c.tar.bz2
[InlineCost] Check that function types match
Retain the behavior we get without opaque pointers: A call to a known function with different function type is considered an indirect call. This fixes the crash reported in https://reviews.llvm.org/D123300#3444772.
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index dd404fc..033ca9a 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -2136,14 +2136,14 @@ bool CallAnalyzer::visitCallBase(CallBase &Call) {
if (isa<CallInst>(Call) && cast<CallInst>(Call).cannotDuplicate())
ContainsNoDuplicateCall = true;
- Value *Callee = Call.getCalledOperand();
- Function *F = dyn_cast_or_null<Function>(Callee);
+ Function *F = Call.getCalledFunction();
bool IsIndirectCall = !F;
if (IsIndirectCall) {
// Check if this happens to be an indirect function call to a known function
// in this inline context. If not, we've done all we can.
+ Value *Callee = Call.getCalledOperand();
F = dyn_cast_or_null<Function>(SimplifiedValues.lookup(Callee));
- if (!F) {
+ if (!F || F->getFunctionType() != Call.getFunctionType()) {
onCallArgumentSetup(Call);
if (!Call.onlyReadsMemory())