[llvm] c2a61ef - Revert "[CallGraph] Ignore callback uses"

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 14:02:51 PDT 2020


Author: Roman Lebedev
Date: 2020-07-10T00:02:07+03:00
New Revision: c2a61ef3885019c5e0444d8789de63e1ce4d5003

URL: https://github.com/llvm/llvm-project/commit/c2a61ef3885019c5e0444d8789de63e1ce4d5003
DIFF: https://github.com/llvm/llvm-project/commit/c2a61ef3885019c5e0444d8789de63e1ce4d5003.diff

LOG: Revert "[CallGraph] Ignore callback uses"

This likely has broken test/Transforms/Attributor/IPConstantProp/ tests.
http://45.33.8.238/linux/22502/step_12.txt

This reverts commit 205dc0922d5f7305226f7457fcbcb4224c92530c.

Added: 
    

Modified: 
    llvm/include/llvm/IR/Function.h
    llvm/lib/Analysis/CallGraph.cpp
    llvm/lib/IR/Function.cpp

Removed: 
    llvm/test/Analysis/CallGraph/ignore-callback-uses.ll


################################################################################
diff  --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h
index bb4ec13c7610..ee66abc3eaed 100644
--- a/llvm/include/llvm/IR/Function.h
+++ b/llvm/include/llvm/IR/Function.h
@@ -830,11 +830,9 @@ class Function : public GlobalObject, public ilist_node<Function> {
 
   /// hasAddressTaken - returns true if there are any uses of this function
   /// other than direct calls or invokes to it, or blockaddress expressions.
-  /// Optionally passes back an offending user for diagnostic purposes and
-  /// ignores callback uses.
+  /// Optionally passes back an offending user for diagnostic purposes.
   ///
-  bool hasAddressTaken(const User ** = nullptr,
-                       bool IgnoreCallbackUses = false) const;
+  bool hasAddressTaken(const User** = nullptr) const;
 
   /// isDefTriviallyDead - Return true if it is trivially safe to remove
   /// this function definition from the module (because it isn't externally

diff  --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp
index 08264512f400..d8abccfdb095 100644
--- a/llvm/lib/Analysis/CallGraph.cpp
+++ b/llvm/lib/Analysis/CallGraph.cpp
@@ -77,11 +77,9 @@ bool CallGraph::invalidate(Module &, const PreservedAnalyses &PA,
 void CallGraph::addToCallGraph(Function *F) {
   CallGraphNode *Node = getOrInsertFunction(F);
 
-  bool IgnoreCallbackUses = true;
-
-  // If this function has external linkage or has its address taken and
-  // it is not a callback, then anything could call it.
-  if (!F->hasLocalLinkage() || F->hasAddressTaken(nullptr, IgnoreCallbackUses))
+  // If this function has external linkage or has its address taken, anything
+  // could call it.
+  if (!F->hasLocalLinkage() || F->hasAddressTaken())
     ExternalCallingNode->addCalledFunction(nullptr, Node);
 
   populateCallGraphNode(Node);

diff  --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 995bc40c362f..0ec0cce83a8c 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -20,7 +20,6 @@
 #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"
@@ -1485,18 +1484,12 @@ 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.
-bool Function::hasAddressTaken(const User **PutOffender,
-                               bool IgnoreCallbackUses) const {
+/// other than direct calls or invokes to it.
+bool Function::hasAddressTaken(const User* *PutOffender) 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)

diff  --git a/llvm/test/Analysis/CallGraph/ignore-callback-uses.ll b/llvm/test/Analysis/CallGraph/ignore-callback-uses.ll
deleted file mode 100644
index 8964ca1efd86..000000000000
--- a/llvm/test/Analysis/CallGraph/ignore-callback-uses.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; RUN: opt < %s -print-callgraph -disable-output 2>&1 | FileCheck %s
-; CHECK: Call graph node <<null function>><<{{.*}}>>  #uses=0
-; CHECK-NEXT:   CS<{{.*}}> calls function 'f'
-; CHECK-NEXT:   CS<{{.*}}> calls function '__kmpc_fork_call'
-; CHECK-EMPTY:
-
-%struct.ident_t = type { i32, i32, i32, i32, i8* }
-
- at 0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
- at 1 = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @0, i32 0, i32 0) }, align 8
-
-; Function Attrs: noinline nounwind optnone uwtable
-define dso_local void @f() {
-entry:
-  br label %omp_parallel
-
-omp_parallel:                                     ; preds = %entry
-  call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @1, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @f..omp_par to void (i32*, i32*, ...)*))
-  br label %omp.par.exit.split
-
-omp.par.exit.split:                               ; preds = %omp_parallel
-  ret void
-}
-
-; Function Attrs: norecurse nounwind
-define internal void @f..omp_par(i32* noalias %tid.addr, i32* noalias %zero.addr) {
-omp.par.entry:
-  %tid.addr.local = alloca i32, align 4
-  %0 = load i32, i32* %tid.addr, align 4
-  store i32 %0, i32* %tid.addr.local, align 4
-  %tid = load i32, i32* %tid.addr.local, align 4
-  br label %omp.par.region
-
-omp.par.exit.split.exitStub:                      ; preds = %omp.par.outlined.exit
-  ret void
-
-omp.par.region:                                   ; preds = %omp.par.entry
-  br label %omp.par.pre_finalize
-
-omp.par.pre_finalize:                             ; preds = %omp.par.region
-  br label %omp.par.outlined.exit
-
-omp.par.outlined.exit:                            ; preds = %omp.par.pre_finalize
-  br label %omp.par.exit.split.exitStub
-}
-
-; Function Attrs: nounwind
-declare !callback !2 void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) #2
-
-!2 = !{!3}
-!3 = !{i64 2, i64 -1, i64 -1, i1 true}


        


More information about the llvm-commits mailing list