diff --git a/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp b/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp index f69febadcd77f..2dc289014200d 100644 --- a/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp +++ b/llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp @@ -175,7 +175,8 @@ bool MachineLateInstrsCleanup::processBlock(MachineBasicBlock *MBB) { Reg2DefMap &MBBDefs = RegDefs[MBB->getNumber()]; // Find reusable definitions in the predecessor(s). - if (!MBB->pred_empty() && !MBB->isEHPad()) { + if (!MBB->pred_empty() && !MBB->isEHPad() && + !MBB->isInlineAsmBrIndirectTarget()) { MachineBasicBlock *FirstPred = *MBB->pred_begin(); for (auto [Reg, DefMI] : RegDefs[FirstPred->getNumber()]) if (llvm::all_of( diff --git a/llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir b/llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir index be6d021a628d9..9a8e5c6341bca 100644 --- a/llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir +++ b/llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir @@ -160,8 +160,9 @@ body: | ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.1.bb8 (machine-block-address-taken, inlineasm-br-indirect-target): ; CHECK-NEXT: successors: %bb.2(0x80000000) - ; CHECK-NEXT: liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x8 + ; CHECK-NEXT: liveins: $w20, $x19, $x21, $x22, $x23, $x24 ; CHECK-NEXT: {{ $}} + ; CHECK-NEXT: renamable $x8 = MOVi64imm 29273397577910035 ; CHECK-NEXT: renamable $x8 = ADDXri killed renamable $x8, 2048, 0 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.2.bb9: