diff options
author | madhur13490 <Madhur.Amilkanthwar@amd.com> | 2021-03-18 18:15:51 +0000 |
---|---|---|
committer | madhur13490 <Madhur.Amilkanthwar@amd.com> | 2021-04-06 09:23:46 +0000 |
commit | 167ea67d76c297eb5dd3fa5f4ffc3c85e1842faa (patch) | |
tree | dd308f90eb060b632218af2db6e480be87db191b /llvm/lib/IR/Function.cpp | |
parent | ddbb58736a3f58b7eed1c0388395504610e5bb68 (diff) | |
download | llvm-167ea67d76c297eb5dd3fa5f4ffc3c85e1842faa.zip llvm-167ea67d76c297eb5dd3fa5f4ffc3c85e1842faa.tar.gz llvm-167ea67d76c297eb5dd3fa5f4ffc3c85e1842faa.tar.bz2 |
[IR] Ignore bitcasts of function pointers which are only used as callees in callbase instruction
This patch enhances hasAddressTaken() to ignore bitcasts as a
callee in callbase instruction. Such bitcast usage doesn't really take
the address in a useful meaningful way.
Reviewed By: rampitec
Differential Revision: https://reviews.llvm.org/D98884
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 1001607..f759771 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -1637,6 +1637,14 @@ bool Function::hasAddressTaken(const User **PutOffender, continue; } + if (isa<BitCastOperator>(FU) && isa<ConstantExpr>(FU) && + llvm::all_of(FU->uses(), [](const Use &U) { + if (const CallBase *CB = dyn_cast<CallBase>(U.getUser())) + return CB->isCallee(&U); + return false; + })) + continue; + const auto *Call = dyn_cast<CallBase>(FU); if (!Call) { if (IgnoreAssumeLikeCalls) { |