aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2022-12-02 19:22:54 -0500
committerMatt Arsenault <Matthew.Arsenault@amd.com>2022-12-16 14:24:03 -0500
commitbf67186bd2a1dcd042219dca408a56ddd06ee16d (patch)
tree1e8baa02fff6357cc5332882cdcea4e32ccd3e72 /llvm/lib/IR/Function.cpp
parent714301d784308c74724ab30ea566fa14fc01d300 (diff)
downloadllvm-bf67186bd2a1dcd042219dca408a56ddd06ee16d.zip
llvm-bf67186bd2a1dcd042219dca408a56ddd06ee16d.tar.gz
llvm-bf67186bd2a1dcd042219dca408a56ddd06ee16d.tar.bz2
Function: Respect IgnoreLLVMUsed with addrspacecasted functions
Try to respect IgnoreLLVMUsed if the function was addrspacecasted to match llvm.used's type.
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index aaef089..cd66eeb 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1905,10 +1905,6 @@ std::optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
return NewDecl;
}
-static bool isPointerCastOperator(const User *U) {
- return isa<AddrSpaceCastOperator>(U) || isa<BitCastOperator>(U);
-}
-
/// hasAddressTaken - returns true if there are any uses of this function
/// other than direct calls or invokes to it. Optionally ignores callback
/// uses, assume like pointer annotation calls, and references in llvm.used
@@ -1930,7 +1926,8 @@ bool Function::hasAddressTaken(const User **PutOffender,
const auto *Call = dyn_cast<CallBase>(FU);
if (!Call) {
- if (IgnoreAssumeLikeCalls && isPointerCastOperator(FU) &&
+ if (IgnoreAssumeLikeCalls &&
+ isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
all_of(FU->users(), [](const User *U) {
if (const auto *I = dyn_cast<IntrinsicInst>(U))
return I->isAssumeLikeIntrinsic();
@@ -1941,8 +1938,8 @@ bool Function::hasAddressTaken(const User **PutOffender,
if (IgnoreLLVMUsed && !FU->user_empty()) {
const User *FUU = FU;
- if (isa<BitCastOperator>(FU) && FU->hasOneUse() &&
- !FU->user_begin()->user_empty())
+ if (isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
+ FU->hasOneUse() && !FU->user_begin()->user_empty())
FUU = *FU->user_begin();
if (llvm::all_of(FUU->users(), [](const User *U) {
if (const auto *GV = dyn_cast<GlobalVariable>(U))