[PATCH] D82686: [NFC] CallGraph related cleanup

Sergey Dmitriev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 14:41:48 PDT 2020


sdmitriev created this revision.
sdmitriev added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Tidy up some CallGraph-related code in preparation for D82572 <https://reviews.llvm.org/D82572>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82686

Files:
  llvm/include/llvm/Analysis/CallGraph.h
  llvm/lib/Analysis/CallGraphSCCPass.cpp
  llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp


Index: llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
+++ llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
@@ -109,8 +109,7 @@
     Optional<Scaled64> Res = None;
     if (!Edge.first)
       return Res;
-    assert(isa<Instruction>(Edge.first));
-    CallBase &CB = cast<CallBase>(*Edge.first);
+    CallBase &CB = *cast<CallBase>(Edge.first);
     Function *Caller = CB.getCaller();
     auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(*Caller);
 
Index: llvm/lib/Analysis/CallGraphSCCPass.cpp
===================================================================
--- llvm/lib/Analysis/CallGraphSCCPass.cpp
+++ llvm/lib/Analysis/CallGraphSCCPass.cpp
@@ -230,17 +230,16 @@
       // If this call site is null, then the function pass deleted the call
       // entirely and the WeakTrackingVH nulled it out.
       auto *Call = dyn_cast_or_null<CallBase>(I->first);
-      if (!I->first ||
+      if (!Call ||
           // If we've already seen this call site, then the FunctionPass RAUW'd
           // one call with another, which resulted in two "uses" in the edge
           // list of the same call.
-          Calls.count(I->first) ||
+          Calls.count(Call) ||
 
           // If the call edge is not from a call or invoke, or it is a
           // instrinsic call, then the function pass RAUW'd a call with
           // another value. This can happen when constant folding happens
           // of well known functions etc.
-          !Call ||
           (Call->getCalledFunction() &&
            Call->getCalledFunction()->isIntrinsic() &&
            Intrinsic::isLeaf(Call->getCalledFunction()->getIntrinsicID()))) {
@@ -267,14 +266,13 @@
         continue;
       }
 
-      assert(!Calls.count(I->first) &&
-             "Call site occurs in node multiple times");
+      assert(!Calls.count(Call) && "Call site occurs in node multiple times");
 
       if (Call) {
         Function *Callee = Call->getCalledFunction();
         // Ignore intrinsics because they're not really function calls.
         if (!Callee || !(Callee->isIntrinsic()))
-          Calls.insert(std::make_pair(I->first, I->second));
+          Calls.insert(std::make_pair(Call, I->second));
       }
       ++I;
     }
Index: llvm/include/llvm/Analysis/CallGraph.h
===================================================================
--- llvm/include/llvm/Analysis/CallGraph.h
+++ llvm/include/llvm/Analysis/CallGraph.h
@@ -412,7 +412,7 @@
 // graphs by the generic graph algorithms.
 //
 
-// Provide graph traits for tranversing call graphs using standard graph
+// Provide graph traits for traversing call graphs using standard graph
 // traversals.
 template <> struct GraphTraits<CallGraphNode *> {
   using NodeRef = CallGraphNode *;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82686.273837.patch
Type: text/x-patch
Size: 2873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200626/51df8168/attachment.bin>


More information about the llvm-commits mailing list