]> granicus.if.org Git - llvm/commitdiff
[BFI]: code cleanup
authorXinliang David Li <davidxl@google.com>
Tue, 28 Jun 2016 00:15:45 +0000 (00:15 +0000)
committerXinliang David Li <davidxl@google.com>
Tue, 28 Jun 2016 00:15:45 +0000 (00:15 +0000)
Expose getBPI interface from BFI impl and use
it in graph viewer. This eliminates the dependency
on old PM interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273967 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/BlockFrequencyInfoImpl.h
include/llvm/CodeGen/MachineBlockFrequencyInfo.h
lib/CodeGen/MachineBlockFrequencyInfo.cpp

index 34739360a65c66fa9b2aa911a8499a6c0438d77e..6315e7efb7df29608f41f34c600a37b357951d2f 100644 (file)
@@ -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.
index 4a881ee354af3ab5bac423d91938f78cbeaff744..7a236086ed09c030cec8ef47ebfea0db23047ccb 100644 (file)
@@ -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
index 689deb8c370d74b90850aa9c1653372c3e8ebd5e..e994aec4e1ef76accb53578b71976947524f2239 100644 (file)
@@ -120,13 +120,14 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *>
   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 *MachineBlockFrequencyInfo::getFunction() const {
   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 {