[PATCH] D13963: Create a new interface addSuccessorWithoutWeight(MBB*) in MBB to add successors when optimization is disabled.

Cong Hou via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 15:46:51 PDT 2015


congh marked an inline comment as done.

================
Comment at: lib/CodeGen/MachineBasicBlock.cpp:511
@@ -516,1 +510,3 @@
+  // diabled optimization) or has the same size as successor list.
+  if (!Weights.empty() || Successors.empty())
     Weights.push_back(Weight);
----------------
davidxl wrote:
> I find it more readable to say
> 
> if (! (Weights.empty() && !Successors.empty())) {
>    ...
> }
> 
> Since this interface is called only when optimization enabled, so 
>  (Weights.empty () && Successors.empty()) == false should be asserted -- basically the above if condition is always  true?
> I find it more readable to say
> 
> if (! (Weights.empty() && !Successors.empty())) {
> 
> ...
> }

Yes.

> 
> Since this interface is called only when optimization enabled, so 
> (Weights.empty () && Successors.empty()) == false should be asserted -- basically the above if condition is always true?

This is not true. When optimization is disabled, this interface can also be called, even the added weights are never used. That is to say, we cannot not guarantee empty weight list when optimization is disabled.




http://reviews.llvm.org/D13963





More information about the llvm-commits mailing list