[PATCH] D19367: [BlockFrequencyInfo] NFC. Add DEBUG output for irregular CFG handling

Yuanfang Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 08:25:20 PDT 2016


kula created this revision.
kula added a reviewer: dexonsmith.
kula added a subscriber: llvm-commits.

Add DEBUG output for irregular CFG handling

http://reviews.llvm.org/D19367

Files:
  include/llvm/Analysis/BlockFrequencyInfoImpl.h
  lib/Analysis/BlockFrequencyInfoImpl.cpp

Index: lib/Analysis/BlockFrequencyInfoImpl.cpp
===================================================================
--- lib/Analysis/BlockFrequencyInfoImpl.cpp
+++ lib/Analysis/BlockFrequencyInfoImpl.cpp
@@ -381,7 +381,7 @@
   for (const BlockNode &M : Loop.Nodes) {
     if (auto *Loop = Working[M.Index].getPackagedLoop())
       Loop->Exits.clear();
-    DEBUG(dbgs() << " - node: " << getBlockName(M.Index) << "\n");
+    DEBUG(dbgs() << " *- node: " << getBlockName(M.Index) << "\n");
   }
   Loop.IsPackaged = true;
 }
@@ -670,6 +670,7 @@
       DEBUG(dbgs() << "  => entry = " << BFI.getBlockName(Irr.Node) << "\n");
     } else {
       Others.push_back(Irr.Node);
+      DEBUG(dbgs() << "  => other = " << BFI.getBlockName(Irr.Node) << "\n");
     }
   }
   assert(Headers.size() >= 2 &&
@@ -750,6 +751,8 @@
   for (auto I = scc_begin(G); !I.isAtEnd(); ++I)
     if (I->size() < 2) {
       assert(I->size() == 1);
+      DEBUG(dbgs() << " - found-trivial-scc " << getBlockName((*I)[0]->Node)
+                   << "\n");
       SingleSCCs.insert(SingleSCCs.begin(), (*I)[0]->Node);
     } else {
       // Translate the SCC into RPO.
Index: include/llvm/Analysis/BlockFrequencyInfoImpl.h
===================================================================
--- include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -22,6 +22,7 @@
 #include "llvm/Support/BlockFrequency.h"
 #include "llvm/Support/BranchProbability.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/ScaledNumber.h"
 #include "llvm/Support/raw_ostream.h"
 #include <deque>
@@ -1129,6 +1130,7 @@
 void BlockFrequencyInfoImpl<BT>::computeStartTerm(
     GeometricMeanInfo &HeaderData, LoopData *Loop, SCCLoopVecTy &SubLoops,
     NodeVecTy &LeftSCCs, std::list<LoopData>::iterator Insert) {
+  DEBUG(dbgs() << "compute start terms\n");
   for (auto &S : SubLoops) {
     // First propagate mass on subloop's dependence nodes.
     for (const auto Node : S.second)
@@ -1171,12 +1173,16 @@
     auto &HeaderNode = Loop->Nodes[H];
     auto &HeaderMass = Working[HeaderNode.Index].getMass();
     HeaderData[HeaderNode].first = HeaderMass;
+    DEBUG(dbgs() << "header start term mass = " << HeaderMass << " ["
+                 << HeaderMass.toScaled() << "] (" << getBlockName(HeaderNode)
+                 << ")\n");
   }
 }
 
 template <class BT>
 void BlockFrequencyInfoImpl<BT>::computeGeometricRatio(
     GeometricMeanInfo &HeaderData, LoopData &Loop) {
+  DEBUG(dbgs() << "compute geometric ratio\n");
   Loop.Scale = BlockMass::getFull().toScaled();
   LoopData::NodeList SortedNodes = Loop.Nodes;
   std::sort(SortedNodes.begin(), SortedNodes.end());
@@ -1205,6 +1211,8 @@
     // to use a/(1-r).
     BlockMass LeftMass = BlockMass::getFull() - HeaderData[HeaderNode].second;
     Scaled64 S = LeftMass.toScaled().inverse();
+    DEBUG(dbgs() << "header ratio = " << S << " (" << getBlockName(HeaderNode)
+                 << ")\n");
     if (S > Loop.Scale)
       Loop.Scale = S;
   }
@@ -1276,6 +1284,14 @@
   GeometricMeanInfo HeaderData;
 
   // Distribute mass among headers according to their input relative weight.
+  DEBUG(dbgs() << "distribute full mass among headers\n");
+  for (const Weight &W : Dist.Weights)
+    DEBUG(dbgs() << "  header weight = "
+                 << format("%*" PRIu64,
+                           std::snprintf(nullptr, 0, "%" PRIu64,
+                                         std::numeric_limits<uint64_t>::max()),
+                           W.Amount)
+                 << " (" << getBlockName(W.TargetNode) << ")\n");
   distributeMass(BlockMass::getFull(), nullptr, Dist);
 
   computeStartTerm(HeaderData, Loop, SubLoops, LeftSCCs, Insert);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19367.54509.patch
Type: text/x-patch
Size: 3754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160421/8b4b72ee/attachment.bin>


More information about the llvm-commits mailing list