[llvm] r207183 - blockfreq: Expose getPackagedNode()

Duncan P. N. Exon Smith dexonsmith at apple.com
Thu Apr 24 21:38:12 PDT 2014


Author: dexonsmith
Date: Thu Apr 24 23:38:12 2014
New Revision: 207183

URL: http://llvm.org/viewvc/llvm-project?rev=207183&view=rev
Log:
blockfreq: Expose getPackagedNode()

Make `getPackagedNode()` a member function of
`BlockFrequencyInfoImplBase` so that it's available for templated code.

<rdar://problem/14292693>

Modified:
    llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
    llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp

Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=207183&r1=207182&r2=207183&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Thu Apr 24 23:38:12 2014
@@ -1093,6 +1093,28 @@ public:
     return *Working[Head.Index].Loop;
   }
 
+  /// \brief Get a possibly packaged node.
+  ///
+  /// Get the node currently representing Node, which could be a containing
+  /// loop.
+  ///
+  /// This function should only be called when distributing mass.  As long as
+  /// there are no irreducilbe edges to Node, then it will have complexity O(1)
+  /// in this context.
+  ///
+  /// In general, the complexity is O(L), where L is the number of loop headers
+  /// Node has been packaged into.  Since this method is called in the context
+  /// of distributing mass, L will be the number of loop headers an early exit
+  /// edge jumps out of.
+  BlockNode getPackagedNode(const BlockNode &Node) {
+    assert(Node.isValid());
+    if (!Working[Node.Index].isPackaged())
+      return Node;
+    if (!Working[Node.Index].isAPackage())
+      return Node;
+    return getPackagedNode(Working[Node.Index].getContainingHeader());
+  }
+
   /// \brief Distribute mass according to a distribution.
   ///
   /// Distributes the mass in Source according to Dist.  If LoopHead.isValid(),

Modified: llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp?rev=207183&r1=207182&r2=207183&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp (original)
+++ llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp Thu Apr 24 23:38:12 2014
@@ -614,29 +614,6 @@ static void cleanup(BlockFrequencyInfoIm
   BFI.Freqs = std::move(SavedFreqs);
 }
 
-/// \brief Get a possibly packaged node.
-///
-/// Get the node currently representing Node, which could be a containing
-/// loop.
-///
-/// This function should only be called when distributing mass.  As long as
-/// there are no irreducilbe edges to Node, then it will have complexity O(1)
-/// in this context.
-///
-/// In general, the complexity is O(L), where L is the number of loop headers
-/// Node has been packaged into.  Since this method is called in the context
-/// of distributing mass, L will be the number of loop headers an early exit
-/// edge jumps out of.
-static BlockNode getPackagedNode(const BlockFrequencyInfoImplBase &BFI,
-                                 const BlockNode &Node) {
-  assert(Node.isValid());
-  if (!BFI.Working[Node.Index].isPackaged())
-    return Node;
-  if (!BFI.Working[Node.Index].isAPackage())
-    return Node;
-  return getPackagedNode(BFI, BFI.Working[Node.Index].getContainingHeader());
-}
-
 /// \brief Get the appropriate mass for a possible pseudo-node loop package.
 ///
 /// Get appropriate mass for Node.  If Node is a loop-header (whose loop has
@@ -682,7 +659,7 @@ void BlockFrequencyInfoImplBase::addToDi
     Dist.addBackedge(OuterLoop->getHeader(), Weight);
     return;
   }
-  BlockNode Resolved = getPackagedNode(*this, Succ);
+  BlockNode Resolved = getPackagedNode(Succ);
   assert(!isLoopHeader(Resolved));
 
   if (Working[Resolved.Index].getContainingLoop() != OuterLoop) {





More information about the llvm-commits mailing list