[PATCH] D42655: [LivePhysRegs] Fix handling of conditional return instructions.

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 17:01:10 PST 2018


MatzeB accepted this revision.
MatzeB added a comment.
This revision is now accepted and ready to land.

Argh:

  ...
      BX_RET 4, killed %cpsr, implicit %r0
      Successors according to CFG: %bb.2(0x40000000 / 0x80000000 = 50.00%)
  ...

A conditional return statement breaks the whole nice logic of MachineBasicBlock::isReturnBlock() returning true or false, since it's clearly neither in this case...

LLVM CodeGen isn't really prepared for predicated code (= instructions that don't necessarily execute) it seemed fine to me when they are all packaged up in a bundle and reasoning about it as a bundle made sense, but this is turning a sure branch into a possible branch and a fallthrough...

Apart from that I have really bad feelings about us using MI this way, I'm fine to push this as a fix for now.



================
Comment at: lib/CodeGen/LivePhysRegs.cpp:228
   const MachineFunction &MF = *MBB.getParent();
-  if (!MBB.isReturnBlock()) {
+  if (!MBB.isReturnBlock() || !MBB.succ_empty()) {
     addPristines(MF);
----------------
Being how unintuitive all of this turned out to be this deserves a comment!


Repository:
  rL LLVM

https://reviews.llvm.org/D42655





More information about the llvm-commits mailing list