[PATCH] D11915: Let edge weight be always greater than zero in both BPI and MBPI.

David via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 09:19:20 PDT 2015


davidxl added a comment.

Since we plan to change [M]MPI interfaces to hide weight which is internal, can we minimize this patch? My understanding is that minimal change is needed to make the weight normalization patch work well with zero weights.


================
Comment at: include/llvm/CodeGen/MachineBasicBlock.h:386
@@ -381,3 +385,3 @@
   /// Note that duplicate Machine CFG edges are not allowed.
-  void addSuccessor(MachineBasicBlock *succ, uint32_t weight = 0);
+  void addSuccessor(MachineBasicBlock *succ, uint32_t weight = DEFAULT_WEIGHT);
 
----------------
Is 16 a good default value to indicate missing information? 

The current underlying (without this patch) assumption in MBPI is that if the weight list is empty, 0 weight represents 'unknown' weight -- otherwise it will be treated as a real zero value weight.  This assumption is of course very weak and can break down at any time.

All these needs to be considered in the new design when weight is eliminated from the profiling related interfaces -- i.e., reserve a special value for unknown 'probability'.

================
Comment at: lib/Analysis/BranchProbabilityInfo.cpp:210
@@ -208,1 +209,3 @@
 
+  // Weight cannot be zero. Here we find out all zero weights read from MD, and
+  // replace them by 1. If any other weight is not zero, we need to normalize
----------------
Which clients produce zero weights ? It seems that Clang FE does not do that. See scaleBranchWeight in tools/clang/lib/CodeGen/CodeGenPGO.cpp


http://reviews.llvm.org/D11915





More information about the llvm-commits mailing list