diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -566,7 +566,7 @@ if (BrInst.isUnconditional()) { // If the unconditional target is the layout successor, fallthrough. - if (!CurMBB.isLayoutSuccessor(Succ0MBB)) + if (OptLevel == CodeGenOpt::None || !CurMBB.isLayoutSuccessor(Succ0MBB)) MIRBuilder.buildBr(*Succ0MBB); // Link successors. diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -2093,17 +2093,8 @@ I.eraseFromParent(); return true; } - case TargetOpcode::G_BR: { - // If the branch jumps to the fallthrough block, don't bother emitting it. - // Only do this for -O0 for a good code size improvement, because when - // optimizations are enabled we want to leave this choice to - // MachineBlockPlacement. - bool EnableOpt = MF.getTarget().getOptLevel() != CodeGenOpt::None; - if (EnableOpt || !MBB.isLayoutSuccessor(I.getOperand(0).getMBB())) - return false; - I.eraseFromParent(); - return true; - } + case TargetOpcode::G_BR: + return false; case TargetOpcode::G_SHL: return earlySelectSHL(I, MRI); case TargetOpcode::G_CONSTANT: { diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-atomic.ll @@ -329,6 +329,7 @@ ; CHECK-NOLSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: ldr w8, [x0] ; CHECK-NOLSE-O0-NEXT: str w8, [sp, #28] ; 4-byte Folded Spill +; CHECK-NOLSE-O0-NEXT: b LBB6_1 ; CHECK-NOLSE-O0-NEXT: LBB6_1: ; %atomicrmw.start ; CHECK-NOLSE-O0-NEXT: ; =>This Loop Header: Depth=1 ; CHECK-NOLSE-O0-NEXT: ; Child Loop BB6_2 Depth 2 @@ -353,7 +354,8 @@ ; CHECK-NOLSE-O0-NEXT: cset w8, eq ; CHECK-NOLSE-O0-NEXT: str w9, [sp, #28] ; 4-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: tbz w8, #0, LBB6_1 -; CHECK-NOLSE-O0-NEXT: ; %bb.5: ; %atomicrmw.end +; CHECK-NOLSE-O0-NEXT: b LBB6_5 +; CHECK-NOLSE-O0-NEXT: LBB6_5: ; %atomicrmw.end ; CHECK-NOLSE-O0-NEXT: ldr w0, [sp, #12] ; 4-byte Folded Reload ; CHECK-NOLSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-NOLSE-O0-NEXT: ret @@ -377,6 +379,7 @@ ; CHECK-LSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-LSE-O0-NEXT: ldr w8, [x0] ; CHECK-LSE-O0-NEXT: str w8, [sp, #28] ; 4-byte Folded Spill +; CHECK-LSE-O0-NEXT: b LBB6_1 ; CHECK-LSE-O0-NEXT: LBB6_1: ; %atomicrmw.start ; CHECK-LSE-O0-NEXT: ; =>This Inner Loop Header: Depth=1 ; CHECK-LSE-O0-NEXT: ldr w8, [sp, #28] ; 4-byte Folded Reload @@ -390,7 +393,8 @@ ; CHECK-LSE-O0-NEXT: cset w8, eq ; CHECK-LSE-O0-NEXT: str w9, [sp, #28] ; 4-byte Folded Spill ; CHECK-LSE-O0-NEXT: tbz w8, #0, LBB6_1 -; CHECK-LSE-O0-NEXT: ; %bb.2: ; %atomicrmw.end +; CHECK-LSE-O0-NEXT: b LBB6_2 +; CHECK-LSE-O0-NEXT: LBB6_2: ; %atomicrmw.end ; CHECK-LSE-O0-NEXT: ldr w0, [sp, #12] ; 4-byte Folded Reload ; CHECK-LSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-LSE-O0-NEXT: ret @@ -418,6 +422,7 @@ ; CHECK-NOLSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: ldr x8, [x0] ; CHECK-NOLSE-O0-NEXT: str x8, [sp, #24] ; 8-byte Folded Spill +; CHECK-NOLSE-O0-NEXT: b LBB7_1 ; CHECK-NOLSE-O0-NEXT: LBB7_1: ; %atomicrmw.start ; CHECK-NOLSE-O0-NEXT: ; =>This Loop Header: Depth=1 ; CHECK-NOLSE-O0-NEXT: ; Child Loop BB7_2 Depth 2 @@ -442,7 +447,8 @@ ; CHECK-NOLSE-O0-NEXT: cset w8, eq ; CHECK-NOLSE-O0-NEXT: str x9, [sp, #24] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: tbz w8, #0, LBB7_1 -; CHECK-NOLSE-O0-NEXT: ; %bb.5: ; %atomicrmw.end +; CHECK-NOLSE-O0-NEXT: b LBB7_5 +; CHECK-NOLSE-O0-NEXT: LBB7_5: ; %atomicrmw.end ; CHECK-NOLSE-O0-NEXT: ldr x0, [sp, #8] ; 8-byte Folded Reload ; CHECK-NOLSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-NOLSE-O0-NEXT: ret @@ -466,6 +472,7 @@ ; CHECK-LSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-LSE-O0-NEXT: ldr x8, [x0] ; CHECK-LSE-O0-NEXT: str x8, [sp, #24] ; 8-byte Folded Spill +; CHECK-LSE-O0-NEXT: b LBB7_1 ; CHECK-LSE-O0-NEXT: LBB7_1: ; %atomicrmw.start ; CHECK-LSE-O0-NEXT: ; =>This Inner Loop Header: Depth=1 ; CHECK-LSE-O0-NEXT: ldr x8, [sp, #24] ; 8-byte Folded Reload @@ -479,7 +486,8 @@ ; CHECK-LSE-O0-NEXT: cset w8, eq ; CHECK-LSE-O0-NEXT: str x9, [sp, #24] ; 8-byte Folded Spill ; CHECK-LSE-O0-NEXT: tbz w8, #0, LBB7_1 -; CHECK-LSE-O0-NEXT: ; %bb.2: ; %atomicrmw.end +; CHECK-LSE-O0-NEXT: b LBB7_2 +; CHECK-LSE-O0-NEXT: LBB7_2: ; %atomicrmw.end ; CHECK-LSE-O0-NEXT: ldr x0, [sp, #8] ; 8-byte Folded Reload ; CHECK-LSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-LSE-O0-NEXT: ret @@ -507,6 +515,7 @@ ; CHECK-NOLSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: ldr w8, [x0] ; CHECK-NOLSE-O0-NEXT: str w8, [sp, #28] ; 4-byte Folded Spill +; CHECK-NOLSE-O0-NEXT: b LBB8_1 ; CHECK-NOLSE-O0-NEXT: LBB8_1: ; %atomicrmw.start ; CHECK-NOLSE-O0-NEXT: ; =>This Loop Header: Depth=1 ; CHECK-NOLSE-O0-NEXT: ; Child Loop BB8_2 Depth 2 @@ -531,7 +540,8 @@ ; CHECK-NOLSE-O0-NEXT: cset w8, eq ; CHECK-NOLSE-O0-NEXT: str w9, [sp, #28] ; 4-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: tbz w8, #0, LBB8_1 -; CHECK-NOLSE-O0-NEXT: ; %bb.5: ; %atomicrmw.end +; CHECK-NOLSE-O0-NEXT: LBB8_5 +; CHECK-NOLSE-O0-NEXT: LBB8_5: ; %atomicrmw.end ; CHECK-NOLSE-O0-NEXT: ldr w0, [sp, #12] ; 4-byte Folded Reload ; CHECK-NOLSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-NOLSE-O0-NEXT: ret @@ -570,6 +580,7 @@ ; CHECK-NOLSE-O0-NEXT: str x0, [sp, #16] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: ldr x8, [x0] ; CHECK-NOLSE-O0-NEXT: str x8, [sp, #24] ; 8-byte Folded Spill +; CHECK-NOLSE-O0-NEXT: b LBB9_1 ; CHECK-NOLSE-O0-NEXT: LBB9_1: ; %atomicrmw.start ; CHECK-NOLSE-O0-NEXT: ; =>This Loop Header: Depth=1 ; CHECK-NOLSE-O0-NEXT: ; Child Loop BB9_2 Depth 2 @@ -593,7 +604,8 @@ ; CHECK-NOLSE-O0-NEXT: cset w8, eq ; CHECK-NOLSE-O0-NEXT: str x9, [sp, #24] ; 8-byte Folded Spill ; CHECK-NOLSE-O0-NEXT: tbz w8, #0, LBB9_1 -; CHECK-NOLSE-O0-NEXT: ; %bb.5: ; %atomicrmw.end +; CHECK-NOLSE-O0-NEXT: b LBB9_5 +; CHECK-NOLSE-O0-NEXT: LBB9_5: ; %atomicrmw.end ; CHECK-NOLSE-O0-NEXT: ldr x0, [sp, #8] ; 8-byte Folded Reload ; CHECK-NOLSE-O0-NEXT: add sp, sp, #32 ; =32 ; CHECK-NOLSE-O0-NEXT: ret diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll --- a/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll +++ b/llvm/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll @@ -87,8 +87,6 @@ ; CHECK: body: ; CHECK: bb.{{[0-9]+}}.{{[a-zA-Z0-9.]+}}: ; CHECK-NEXT: successors: %[[END:bb.[0-9]+]](0x80000000) -; We don't emit a branch here, as we can fallthrough to the successor. -; CHECK-NOT: G_BR ; CHECK: [[END]].{{[a-zA-Z0-9.]+}}: ; CHECK-NEXT: RET_ReallyLR define void @uncondbr_fallthrough() { @@ -137,7 +135,6 @@ ; CHECK: bb.{{[0-9]+.[a-zA-Z0-9.]+}}: ; Make sure we have one successor ; CHECK-NEXT: successors: %[[BB_L1:bb.[0-9]+]](0x80000000) -; CHECK-NOT: G_BR ; ; Check basic block L1 has 2 successors: BBL1 and BBL2 ; CHECK: [[BB_L1]].{{[a-zA-Z0-9.]+}} (address-taken): diff --git a/llvm/test/CodeGen/AArch64/unwind-preserved.ll b/llvm/test/CodeGen/AArch64/unwind-preserved.ll --- a/llvm/test/CodeGen/AArch64/unwind-preserved.ll +++ b/llvm/test/CodeGen/AArch64/unwind-preserved.ll @@ -365,7 +365,8 @@ ; GISEL-NEXT: bl may_throw_neon ; GISEL-NEXT: str q0, [sp, #16] // 16-byte Folded Spill ; GISEL-NEXT: .Ltmp4: -; GISEL-NEXT: // %bb.1: // %.Lcontinue +; GISEL-NEXT: b .LBB1_1 +; GISEL-NEXT: .LBB1_1: // %.Lcontinue ; GISEL-NEXT: ldr q0, [sp, #16] // 16-byte Folded Reload ; GISEL-NEXT: ldp x29, x30, [sp, #288] // 16-byte Folded Reload ; GISEL-NEXT: ldp q9, q8, [sp, #256] // 32-byte Folded Reload diff --git a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll --- a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll +++ b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/jump_table_and_brjt.ll @@ -55,8 +55,9 @@ ; MIPS32-NEXT: jr $ra ; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_6: # %sw.default -; MIPS32-NEXT: .insn -; MIPS32-NEXT: # %bb.7: # %sw.epilog +; MIPS32-NEXT: j $BB0_7 +; MIPS32-NEXT: nop +; MIPS32-NEXT: $BB0_7: # %sw.epilog ; MIPS32-NEXT: lw $1, 8($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ori $3, $zero, 8 @@ -158,8 +159,9 @@ ; MIPS32_PIC-NEXT: jr $ra ; MIPS32_PIC-NEXT: nop ; MIPS32_PIC-NEXT: $BB0_6: # %sw.default -; MIPS32_PIC-NEXT: .insn -; MIPS32_PIC-NEXT: # %bb.7: # %sw.epilog +; MIPS32_PIC-NEXT: b $BB0_7 +; MIPS32_PIC-NEXT: nop +; MIPS32_PIC-NEXT: $BB0_7: # %sw.epilog ; MIPS32_PIC-NEXT: lw $1, 16($sp) # 4-byte Folded Reload ; MIPS32_PIC-NEXT: lw $2, 12($sp) # 4-byte Folded Reload ; MIPS32_PIC-NEXT: ori $3, $zero, 8 diff --git a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s32.ll b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s32.ll --- a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s32.ll +++ b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s32.ll @@ -57,6 +57,8 @@ ; MIPS32-NEXT: lw $1, 40($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 16($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB0_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_9: # %b.PHI.1 ; MIPS32-NEXT: lw $1, 28($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload @@ -93,6 +95,8 @@ ; MIPS32-NEXT: lw $1, 36($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB0_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 24($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload @@ -244,6 +248,8 @@ ; MIPS32-NEXT: lw $1, 44($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB1_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB1_9: # %b.PHI.1 ; MIPS32-NEXT: lw $2, 52($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 32($sp) # 4-byte Folded Reload @@ -282,6 +288,8 @@ ; MIPS32-NEXT: lw $1, 40($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB1_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB1_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 28($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload @@ -432,6 +440,8 @@ ; MIPS32-NEXT: lw $1, 40($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 16($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB2_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB2_9: # %b.PHI.1 ; MIPS32-NEXT: lw $1, 28($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload @@ -468,6 +478,8 @@ ; MIPS32-NEXT: lw $1, 36($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($1) ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB2_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB2_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 24($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload @@ -620,6 +632,8 @@ ; MIPS32-NEXT: lw $1, 44($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lwc1 $f0, 0($1) ; MIPS32-NEXT: swc1 $f0, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB3_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB3_9: # %b.PHI.1 ; MIPS32-NEXT: lwc1 $f0, 52($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 32($sp) # 4-byte Folded Reload @@ -658,6 +672,8 @@ ; MIPS32-NEXT: lw $1, 40($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lwc1 $f0, 0($1) ; MIPS32-NEXT: swc1 $f0, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB3_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB3_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 28($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lwc1 $f0, 4($sp) # 4-byte Folded Reload diff --git a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s64.ll b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s64.ll --- a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s64.ll +++ b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/long_ambiguous_chain_s64.ll @@ -57,6 +57,8 @@ ; MIPS32-NEXT: lw $1, 64($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 32($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB0_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_9: # %b.PHI.1 ; MIPS32-NEXT: lw $1, 52($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 32($sp) # 8-byte Folded Reload @@ -93,6 +95,8 @@ ; MIPS32-NEXT: lw $1, 60($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 8($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB0_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 48($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 8($sp) # 8-byte Folded Reload @@ -250,6 +254,8 @@ ; MIPS32-NEXT: lw $1, 4($1) ; MIPS32-NEXT: sw $2, 40($sp) # 4-byte Folded Spill ; MIPS32-NEXT: sw $1, 44($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB1_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB1_9: # %b.PHI.1 ; MIPS32-NEXT: lw $2, 76($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 56($sp) # 4-byte Folded Reload @@ -299,6 +305,8 @@ ; MIPS32-NEXT: lw $1, 4($1) ; MIPS32-NEXT: sw $2, 8($sp) # 4-byte Folded Spill ; MIPS32-NEXT: sw $1, 12($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB1_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB1_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 52($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $3, 8($sp) # 4-byte Folded Reload @@ -463,6 +471,8 @@ ; MIPS32-NEXT: lw $1, 64($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 32($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB2_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB2_9: # %b.PHI.1 ; MIPS32-NEXT: lw $1, 52($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 32($sp) # 8-byte Folded Reload @@ -499,6 +509,8 @@ ; MIPS32-NEXT: lw $1, 60($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 8($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB2_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB2_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 48($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 8($sp) # 8-byte Folded Reload @@ -653,6 +665,8 @@ ; MIPS32-NEXT: lw $1, 72($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 40($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB3_9 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB3_9: # %b.PHI.1 ; MIPS32-NEXT: ldc1 $f0, 80($sp) # 8-byte Folded Reload ; MIPS32-NEXT: lw $1, 60($sp) # 4-byte Folded Reload @@ -691,6 +705,8 @@ ; MIPS32-NEXT: lw $1, 68($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($1) ; MIPS32-NEXT: sdc1 $f0, 8($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB3_16 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB3_16: # %b.PHI.2 ; MIPS32-NEXT: lw $1, 56($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 8($sp) # 8-byte Folded Reload diff --git a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/phi.ll b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/phi.ll --- a/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/phi.ll +++ b/llvm/test/CodeGen/Mips/GlobalISel/llvm-ir/phi.ll @@ -22,6 +22,8 @@ ; MIPS32-NEXT: $BB0_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB0_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB0_4: # %cond.end ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: addiu $sp, $sp, 16 @@ -62,6 +64,8 @@ ; MIPS32-NEXT: $BB1_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB1_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB1_4: # %cond.end ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: addiu $sp, $sp, 16 @@ -102,6 +106,8 @@ ; MIPS32-NEXT: $BB2_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB2_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB2_4: # %cond.end ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: addiu $sp, $sp, 16 @@ -142,6 +148,8 @@ ; MIPS32-NEXT: $BB3_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB3_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB3_4: # %cond.end ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: addiu $sp, $sp, 16 @@ -192,6 +200,8 @@ ; MIPS32-NEXT: lw $2, 16($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $2, 0($sp) # 4-byte Folded Spill ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB4_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB4_4: # %cond.end ; MIPS32-NEXT: lw $2, 0($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $3, 4($sp) # 4-byte Folded Reload @@ -236,6 +246,8 @@ ; MIPS32-NEXT: $BB5_3: # %cond.false ; MIPS32-NEXT: ldc1 $f0, 24($sp) # 8-byte Folded Reload ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB5_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB5_4: # %cond.end ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: ldc1 $f0, 0($sp) # 8-byte Folded Reload @@ -281,6 +293,8 @@ ; MIPS32-NEXT: $BB6_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 4($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB6_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB6_4: # %cond.end ; MIPS32-NEXT: lw $1, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: mtc1 $1, $f0 @@ -325,6 +339,8 @@ ; MIPS32-NEXT: $BB7_3: # %cond.false ; MIPS32-NEXT: lw $1, 12($sp) # 4-byte Folded Reload ; MIPS32-NEXT: sw $1, 0($sp) # 4-byte Folded Spill +; MIPS32-NEXT: j $BB7_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB7_4: # %cond.end ; MIPS32-NEXT: lw $2, 4($sp) # 4-byte Folded Reload ; MIPS32-NEXT: lw $1, 0($sp) # 4-byte Folded Reload @@ -372,6 +388,8 @@ ; MIPS32-NEXT: $BB8_3: # %cond.false ; MIPS32-NEXT: ldc1 $f0, 16($sp) # 8-byte Folded Reload ; MIPS32-NEXT: sdc1 $f0, 0($sp) # 8-byte Folded Spill +; MIPS32-NEXT: j $BB8_4 +; MIPS32-NEXT: nop ; MIPS32-NEXT: $BB8_4: # %cond.end ; MIPS32-NEXT: ldc1 $f0, 0($sp) # 8-byte Folded Reload ; MIPS32-NEXT: addiu $sp, $sp, 24 diff --git a/llvm/test/DebugInfo/AArch64/fallthrough-branch.ll b/llvm/test/DebugInfo/AArch64/fallthrough-branch.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/AArch64/fallthrough-branch.ll @@ -0,0 +1,48 @@ +; RUN: llc -O0 -stop-before=livedebugvalues < %s | FileCheck %s + +; ModuleID = '/tmp/t.o' +source_filename = "/tmp/t.o" +target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" +target triple = "arm64-apple-macosx11.0.0" + +define swiftcc void @"$s1t1f1bySb_tF"(i1 %0) !dbg !35 { + %2 = alloca i1, align 8 + %3 = bitcast i1* %2 to i8* + call void @llvm.memset.p0i8.i64(i8* align 8 %3, i8 0, i64 1, i1 false) + store i1 %0, i1* %2, align 8, !dbg !37 +; CHECK: B %bb.1, debug-location !{{[0-9]+}} + br i1 %0, label %4, label %5, !dbg !38 + +4: ; preds = %1 +; Check that at -O0 the branches and their debug locations are not eliminated. +; CHECK: B %bb.3, debug-location !{{[0-9]+}} + br label %6, !dbg !39 + +5: ; preds = %1 +; CHECK: B %bb.3, debug-location !{{[0-9]+}} + br label %6, !dbg !40 + +6: ; preds = %4, %5 + ret void, !dbg !39 +} + +; Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly +declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #1 +attributes #1 = { argmemonly nofree nosync nounwind willreturn writeonly } + +!llvm.module.flags = !{!6, !7, !14} +!llvm.dbg.cu = !{!15, !27} + +!6 = !{i32 7, !"Dwarf Version", i32 4} +!7 = !{i32 2, !"Debug Info Version", i32 3} +!14 = !{i32 1, !"Swift Version", i32 7} +!15 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !16, producer: "Swift", emissionKind: LineTablesOnly) +!16 = !DIFile(filename: "t.swift", directory: "/tmp") +!17 = !{} +!27 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !16, emissionKind: LineTablesOnly) +!35 = distinct !DISubprogram(name: "f", linkageName: "$s1t1f1bySb_tF", scope: !15, file: !16, line: 1, type: !36, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !15, retainedNodes: !17) +!36 = !DISubroutineType(types: null) +!37 = !DILocation(line: 0, scope: !35) +!38 = !DILocation(line: 2, column: 9, scope: !35) +!39 = !DILocation(line: 3, column: 1, scope: !35) +!40 = !DILocation(line: 2, column: 18, scope: !35)