[PATCH] D142924: [llvm][IfConversion] update successor list when merging INLINEASM_BR
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 13:00:01 PST 2023
nickdesaulniers updated this revision to Diff 493388.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.
- update commit message
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142924/new/
https://reviews.llvm.org/D142924
Files:
llvm/lib/CodeGen/IfConversion.cpp
llvm/test/CodeGen/ARM/inlineasmbr-if-cvt.mir
Index: llvm/test/CodeGen/ARM/inlineasmbr-if-cvt.mir
===================================================================
--- llvm/test/CodeGen/ARM/inlineasmbr-if-cvt.mir
+++ llvm/test/CodeGen/ARM/inlineasmbr-if-cvt.mir
@@ -80,14 +80,23 @@
body: |
; CHECK-LABEL: name: tusb1210_chg_det_work
; CHECK: bb.0.entry:
- ; CHECK-NEXT: successors:
+ ; CHECK-NEXT: successors: %bb.1(0x80000000), %bb.2(0x80000000)
; CHECK-NEXT: liveins: $r0
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: TSTri killed renamable $r0, 1, 14 /* CC::al */, $noreg, implicit-def $cpsr
; CHECK-NEXT: renamable $r0 = MOVi 0, 1 /* CC::ne */, $cpsr, $noreg
- ; CHECK-NEXT: dead renamable $r0 = MOVi 1, 0 /* CC::eq */, killed $cpsr, $noreg, implicit killed $r0
- ; FIXME: %bb.-1 is a dangling reference!!!
- ; CHECK-NEXT: INLINEASM_BR &".word b, ${1:l}, ${0:c}\0A\09", 9 /* sideeffect mayload attdialect */, 13 /* imm */, 0, 13 /* imm */, %bb.-1
+ ; CHECK-NEXT: renamable $r0 = MOVi 1, 0 /* CC::eq */, killed $cpsr, $noreg, implicit killed $r0
+ ; CHECK-NEXT: INLINEASM_BR &".word b, ${1:l}, ${0:c}\0A\09", 9 /* sideeffect mayload attdialect */, 13 /* imm */, 0, 13 /* imm */, %bb.1
+ ; CHECK-NEXT: B %bb.2
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.1.if.end.sink.split (machine-block-address-taken, inlineasm-br-indirect-target):
+ ; CHECK-NEXT: successors: %bb.2(0x80000000)
+ ; CHECK-NEXT: liveins: $r0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: renamable $r1 = MOVi 0, 14 /* CC::al */, $noreg, $noreg
+ ; CHECK-NEXT: STRi12 killed renamable $r0, killed renamable $r1, 0, 14 /* CC::al */, $noreg :: (store (s32) into `ptr null`)
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: bb.2.if.end:
; CHECK-NEXT: BX_RET 14 /* CC::al */, $noreg
bb.0.entry:
successors: %bb.4(0x40000000), %bb.1(0x40000000)
Index: llvm/lib/CodeGen/IfConversion.cpp
===================================================================
--- llvm/lib/CodeGen/IfConversion.cpp
+++ llvm/lib/CodeGen/IfConversion.cpp
@@ -2244,6 +2244,15 @@
assert(!FromMBB.hasAddressTaken() &&
"Removing a BB whose address is taken!");
+ // If we're about to splice an INLINEASM_BR from FromBBI, we need to update
+ // ToBBI's successor list accordingly.
+ if (FromMBB.mayHaveInlineAsmBr())
+ for (MachineInstr &MI : FromMBB)
+ if (MI.getOpcode() == TargetOpcode::INLINEASM_BR)
+ for (MachineOperand &MO : MI.operands())
+ if (MO.isMBB() && !ToBBI.BB->isSuccessor(MO.getMBB()))
+ ToBBI.BB->addSuccessor(MO.getMBB(), BranchProbability::getZero());
+
// In case FromMBB contains terminators (e.g. return instruction),
// first move the non-terminator instructions, then the terminators.
MachineBasicBlock::iterator FromTI = FromMBB.getFirstTerminator();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142924.493388.patch
Type: text/x-patch
Size: 2793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230130/7ecf9ce0/attachment.bin>
More information about the llvm-commits
mailing list