aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorGiorgis Georgakoudis <georgakoudis1@llnl.gov>2020-07-07 22:43:24 -0700
committerGiorgis Georgakoudis <georgakoudis1@llnl.gov>2020-07-09 13:13:46 -0700
commit205dc0922d5f7305226f7457fcbcb4224c92530c (patch)
tree7404d8ab0bf82277fcbce72aa50048419c6e006e /llvm/lib/IR/Function.cpp
parent03640ee0fa73c6eaf8cb12050203027239136789 (diff)
downloadllvm-205dc0922d5f7305226f7457fcbcb4224c92530c.zip
llvm-205dc0922d5f7305226f7457fcbcb4224c92530c.tar.gz
llvm-205dc0922d5f7305226f7457fcbcb4224c92530c.tar.bz2
[CallGraph] Ignore callback uses
Summary: Ignore callback uses when adding a callback function in the CallGraph. Callback functions are typically created when outlining, e.g. for OpenMP, so they have internal scope and linkage. They should not be added to the ExternalCallingNode since they are only callable by the specified caller function at creation time. A CGSCC pass, such as OpenMPOpt, may need to update the CallGraph by adding a new outlined callback function. Without ignoring callback uses, adding breaks CGSCC pass restrictions and results to a broken CallGraph. Reviewers: jdoerfert Subscribers: hiraditya, sstefan1, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D83370
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 0ec0cce..995bc40 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -20,6 +20,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/IR/AbstractCallSite.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
@@ -1484,12 +1485,18 @@ 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.
-bool Function::hasAddressTaken(const User* *PutOffender) const {
+/// other than direct calls or invokes to it. Optionally ignores callback
+/// uses.
+bool Function::hasAddressTaken(const User **PutOffender,
+ bool IgnoreCallbackUses) const {
for (const Use &U : uses()) {
const User *FU = U.getUser();
if (isa<BlockAddress>(FU))
continue;
+
+ if (IgnoreCallbackUses && AbstractCallSite(&U))
+ continue;
+
const auto *Call = dyn_cast<CallBase>(FU);
if (!Call) {
if (PutOffender)