[PATCH] Propagation of profile samples through the CFG.

Chandler Carruth chandlerc at gmail.com
Fri Jan 10 14:04:28 PST 2014


  I think this is in a good state to go in. There is more work to do here, but the most important thing is to get some data on how well this works, and then we'll know which direction to pursue.

  Some nit picks below, but LGTM with those addressed.


================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:544-551
@@ -451,3 +543,10 @@
 ///
-/// Once all the branch weights are computed, we emit the MD_prof
-/// metadata on B using the computed values.
+/// This traverses all the the deescendants of \p BB1 in
+/// \p BB1's dominator tree (if \p CheckDT is true). For
+/// each BB2 found that post-dominates \p BB1 and is
+/// in the same loop as \p BB1, BB2's equivalence class
+/// is set to BB1.
+///
+/// If \p CheckDT is false, the complementary check is
+/// performed with \p BB1's post-dominator tree.
+///
----------------
This comment is a bit out of date.

================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:558
@@ +557,3 @@
+    BasicBlock *BB1, SmallVector<BasicBlock *, 8> Descendants,
+    DominatorTreeBase<BasicBlock> *DomTree) {
+  for (SmallVectorImpl<BasicBlock *>::iterator I = Descendants.begin(),
----------------
It would be good to clarify that this is the "other" dom tree from Descendants. Not sure twhat the best name is here. Maybe InverseDomTree? It's not really an inverse though.

================
Comment at: lib/Transforms/Scalar/SampleProfile.cpp:594-595
@@ +593,4 @@
+void SampleFunctionProfile::findEquivalenceClasses(Function &F) {
+  SmallVector<BasicBlock *, 8> DominatedBBs;
+  SmallVector<BasicBlock *, 8> PostDominatedBBs;
+  DEBUG(dbgs() << "\nBlock equivalence classes\n");
----------------
You only need one SmallVector? You can clear and re-use it.


http://llvm-reviews.chandlerc.com/D2274



More information about the llvm-commits mailing list