aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2023-08-29 16:37:03 -0700
committerJohannes Doerfert <johannes@jdoerfert.de>2023-08-31 19:32:52 -0700
commit209496b766bb08f43155d38dc8015804fb6c0c96 (patch)
treec3584e0bd0c16366c9a0a33bdb4c9d4d02793565 /llvm/lib/IR/Function.cpp
parent6e42f905ae215fbf0c92b57780b64b274cc7e206 (diff)
downloadllvm-209496b766bb08f43155d38dc8015804fb6c0c96.zip
llvm-209496b766bb08f43155d38dc8015804fb6c0c96.tar.gz
llvm-209496b766bb08f43155d38dc8015804fb6c0c96.tar.bz2
[Core] Allow `hasAddressTaken` to ignore "casted direct calls"
A direct call to a function casted to a different type is still not really an address taken event. We allow the user to opt out of these now. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D159149
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index a9beb0b..b1b8404 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1752,7 +1752,8 @@ std::optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
bool Function::hasAddressTaken(const User **PutOffender,
bool IgnoreCallbackUses,
bool IgnoreAssumeLikeCalls, bool IgnoreLLVMUsed,
- bool IgnoreARCAttachedCall) const {
+ bool IgnoreARCAttachedCall,
+ bool IgnoreCastedDirectCall) const {
for (const Use &U : uses()) {
const User *FU = U.getUser();
if (isa<BlockAddress>(FU))
@@ -1801,7 +1802,8 @@ bool Function::hasAddressTaken(const User **PutOffender,
continue;
}
- if (!Call->isCallee(&U) || Call->getFunctionType() != getFunctionType()) {
+ if (!Call->isCallee(&U) || (!IgnoreCastedDirectCall &&
+ Call->getFunctionType() != getFunctionType())) {
if (IgnoreARCAttachedCall &&
Call->isOperandBundleOfType(LLVMContext::OB_clang_arc_attachedcall,
U.getOperandNo()))