[llvm] r273967 - [BFI]: code cleanup

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 17:15:45 PDT 2016


Author: davidxl
Date: Mon Jun 27 19:15:45 2016
New Revision: 273967

URL: http://llvm.org/viewvc/llvm-project?rev=273967&view=rev
Log:
[BFI]: code cleanup 

Expose getBPI interface from BFI impl and use
it in graph viewer. This eliminates the dependency
on old PM interface.


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

Modified: llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h?rev=273967&r1=273966&r2=273967&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/BlockFrequencyInfoImpl.h Mon Jun 27 19:15:45 2016
@@ -927,6 +927,8 @@ public:
     return BlockFrequencyInfoImplBase::getFloatingBlockFreq(getNode(BB));
   }
 
+  const BranchProbabilityInfoT &getBPI() const { return *BPI; }
+
   /// \brief Print the frequencies for the current function.
   ///
   /// Prints the frequencies for the blocks in the current function.

Modified: llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h?rev=273967&r1=273966&r2=273967&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBlockFrequencyInfo.h Mon Jun 27 19:15:45 2016
@@ -54,6 +54,7 @@ public:
   Optional<uint64_t> getBlockProfileCount(const MachineBasicBlock *MBB) const;
 
   const MachineFunction *getFunction() const;
+  const MachineBranchProbabilityInfo *getMBPI() const;
   void view() const;
 
   // Print the block frequency Freq to OS using the current functions entry

Modified: llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp?rev=273967&r1=273966&r2=273967&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp Mon Jun 27 19:15:45 2016
@@ -120,13 +120,14 @@ struct DOTGraphTraits<MachineBlockFreque
   static std::string getEdgeAttributes(const MachineBasicBlock *Node,
                                        EdgeIter EI,
                                        const MachineBlockFrequencyInfo *MBFI) {
-    MachineBranchProbabilityInfo &MBPI =
-        MBFI->getAnalysis<MachineBranchProbabilityInfo>();
-    BranchProbability BP = MBPI.getEdgeProbability(Node, EI);
+    std::string Str;
+    const MachineBranchProbabilityInfo *MBPI = MBFI->getMBPI();
+    if (!MBPI)
+      return Str;
+    BranchProbability BP = MBPI->getEdgeProbability(Node, EI);
     uint32_t N = BP.getNumerator();
     uint32_t D = BP.getDenominator();
     double Percent = 100.0 * N / D;
-    std::string Str;
     raw_string_ostream OS(Str);
     OS << format("label=\"%.1f%%\"", Percent);
     OS.flush();
@@ -207,6 +208,10 @@ const MachineFunction *MachineBlockFrequ
   return MBFI ? MBFI->getFunction() : nullptr;
 }
 
+const MachineBranchProbabilityInfo *MachineBlockFrequencyInfo::getMBPI() const {
+  return MBFI ? &MBFI->getBPI() : nullptr;
+}
+
 raw_ostream &
 MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS,
                                           const BlockFrequency Freq) const {




More information about the llvm-commits mailing list