diff options
| author | Tim Northover <tnorthover@apple.com> | 2017-11-14 11:43:54 +0000 |
|---|---|---|
| committer | Tim Northover <tnorthover@apple.com> | 2017-11-14 11:43:54 +0000 |
| commit | 5cdc4f9c330c7d4d411e1bbc77084c1415593ded (patch) | |
| tree | 6271b8501dbad98cded7989efa08065e6bc65bb5 /llvm | |
| parent | 7a91c08414b86eaa8d48d71847d09bde8a075d79 (diff) | |
| download | bcm5719-llvm-5cdc4f9c330c7d4d411e1bbc77084c1415593ded.tar.gz bcm5719-llvm-5cdc4f9c330c7d4d411e1bbc77084c1415593ded.zip | |
ARM: correctly update CFG when splitting BB to fix branch.
Because the block-splitting code is multi-purpose, we have to meddle with the
branches when using it to fixup a conditional branch destination. We got the
code right, but forgot to update the CFG so the verifier complained when
expensive checks were on.
Probably harmless since constant-islands comes so late, but best to fix it
anyway.
llvm-svn: 318148
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMConstantIslandPass.cpp | 6 | ||||
| -rw-r--r-- | llvm/test/CodeGen/ARM/constant-islands-cfg.mir | 64 |
2 files changed, 70 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp index 79356d70b62..e318a862405 100644 --- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -1689,6 +1689,12 @@ ARMConstantIslands::fixupConditionalBr(ImmBranch &Br) { int delta = TII->getInstSizeInBytes(MBB->back()); BBInfo[MBB->getNumber()].Size -= delta; MBB->back().eraseFromParent(); + + // The conditional successor will be swapped between the BBs after this, so + // update CFG. + MBB->addSuccessor(DestBB); + std::next(MBB->getIterator())->removeSuccessor(DestBB); + // BBInfo[SplitBB].Offset is wrong temporarily, fixed below } MachineBasicBlock *NextBB = &*++MBB->getIterator(); diff --git a/llvm/test/CodeGen/ARM/constant-islands-cfg.mir b/llvm/test/CodeGen/ARM/constant-islands-cfg.mir new file mode 100644 index 00000000000..66d854393b5 --- /dev/null +++ b/llvm/test/CodeGen/ARM/constant-islands-cfg.mir @@ -0,0 +1,64 @@ +# RUN: llc -mtriple=thumbv6m-apple-ios -run-pass=arm-cp-islands %s -o - | FileCheck %s +--- | + ; Function Attrs: minsize nounwind optsize uwtable + define arm_aapcscc double @test_split_cfg(double %a, double %b) local_unnamed_addr #0 { + ret double undef + } +... +--- +name: test_split_cfg +alignment: 1 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +tracksRegLiveness: true +registers: +liveins: + - { reg: '%r0', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 48 + offsetAdjustment: 0 + maxAlignment: 4 + adjustsStack: true + hasCalls: true + stackProtector: '' + maxCallFrameSize: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + savePoint: '' + restorePoint: '' +fixedStack: +# CHECK-LABEL: name: test_split_cfg +# CHECK: bb.0: +# CHECK: successors: %[[LONG_BR_BB:bb.[0-9]+]](0x{{[0-9a-f]+}}), %[[DEST1:bb.[0-9]+]](0x{{[0-9a-f]+}}){{$}} +# CHECK: tBcc %[[LONG_BR_BB]], 0, %cpsr +# CHECK: tB %[[DEST1]] +# CHECK: [[LONG_BR_BB]]: +# CHECK: successors: %[[DEST2:bb.[0-9]+]](0x{{[0-9a-f]+}}){{$}} +# CHECK: tB %[[DEST2]] +# CHECK: [[DEST1]]: +# CHECK: [[DEST2]]: + +body: | + bb.0: + liveins: %r0 + tCMPi8 killed %r0, 0, 14, _, implicit-def %cpsr + tBcc %bb.2, 1, killed %cpsr + tB %bb.3, 14, _ + + bb.1: + dead %r0 = SPACE 256, undef %r0 + + bb.2: + tPOP_RET 14, _, def %pc + + bb.3: + tPOP_RET 14, _, def %pc + +... |

