[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
Wed Oct 21 16:27:11 PDT 2015


congh created this revision.
congh added reviewers: dexonsmith, davidxl.
congh added a subscriber: llvm-commits.

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.

http://reviews.llvm.org/D13963

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13963.38059.patch
Type: text/x-patch
Size: 7040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151021/8efcf4c8/attachment.bin>


More information about the llvm-commits mailing list