aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2021-02-04 14:38:40 -0800
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>2021-02-25 09:48:29 -0800
commit29e2d9461a91b76665139002a5b323fbb1b19d82 (patch)
tree4a1f4867042c40118b2fd610c980bc0a0af0709c /llvm/lib/IR/Function.cpp
parent7f6e3316456f939a062aad0eeaac983251a1747c (diff)
Option to ignore assume like intrinsic uses in hasAddressTaken()
Differential Revision: https://reviews.llvm.org/D96081
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 17247123f87f..c6932f0ec446 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -31,6 +31,7 @@
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsAArch64.h"
#include "llvm/IR/IntrinsicsAMDGPU.h"
@@ -1578,9 +1579,10 @@ Optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
/// hasAddressTaken - returns true if there are any uses of this function
/// other than direct calls or invokes to it. Optionally ignores callback
-/// uses.
+/// uses and assume like pointer annotation calls.
bool Function::hasAddressTaken(const User **PutOffender,
- bool IgnoreCallbackUses) const {
+ bool IgnoreCallbackUses,
+ bool IgnoreAssumeLikeCalls) const {
for (const Use &U : uses()) {
const User *FU = U.getUser();
if (isa<BlockAddress>(FU))
@@ -1594,6 +1596,17 @@ bool Function::hasAddressTaken(const User **PutOffender,
const auto *Call = dyn_cast<CallBase>(FU);
if (!Call) {
+ if (IgnoreAssumeLikeCalls) {
+ if (const auto *FI = dyn_cast<Instruction>(FU)) {
+ if (FI->isCast() && !FI->user_empty() &&
+ llvm::all_of(FU->users(), [](const User *U) {
+ if (const auto *I = dyn_cast<IntrinsicInst>(U))
+ return I->isAssumeLikeIntrinsic();
+ return false;
+ }))
+ continue;
+ }
+ }
if (PutOffender)
*PutOffender = FU;
return true;