Create a new interface addSuccessorWithoutWeight(MBB*) in MBB to add successors when...
authorCong Hou <congh@google.com>
Tue, 27 Oct 2015 17:59:36 +0000 (17:59 +0000)
committerCong Hou <congh@google.com>
Tue, 27 Oct 2015 17:59:36 +0000 (17:59 +0000)
commitd4f04a7e27ac8e24c47dd646b293e305881ea336
treed31f9f821d797a5520dd2472b2263674f9f77ab0
parent63fe1641e4f427e1283cddab98f8bf1c3790f064
Create a new interface addSuccessorWithoutWeight(MBB*) in MBB to add successors when optimization is disabled.

When optimization is disabled, edge weights that are stored in MBB won't be used so that we don't have to store them. Currently, this is done by adding successors with default weight 0, and if all successors have default weights, the weight list will be empty. But that the weight list is empty doesn't mean disabled optimization (as is stated several times in MachineBasicBlock.cpp): it may also mean all successors just have default weights.

We should discourage using default weights when adding successors, because it is very easy for users to forget update the correct edge weights instead of using default ones (one exception is that the MBB only has one successor). In order to detect such usages, it is better to differentiate using default weights from the case when optimizations is disabled.

In this patch, a new interface addSuccessorWithoutWeight(MBB*) is created for when optimization is disabled. In this case, MBB will try to maintain an empty weight list, but it cannot guarantee this as for many uses of addSuccessor() whether optimization is disabled or not is not checked. But it can guarantee that if optimization is enabled, then the weight list always has the same size of the successor list.

Differential revision: http://reviews.llvm.org/D13963

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251429 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MachineBasicBlock.cpp
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/Target/AArch64/AArch64FastISel.cpp
test/CodeGen/MIR/X86/newline-handling.mir
test/CodeGen/MIR/X86/successor-basic-blocks.mir