diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 9e17cab10643..5d4dfaab4503 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -33765,7 +33765,6 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, case X86::LCMPXCHG16B_NO_RBX: { const X86RegisterInfo *TRI = Subtarget.getRegisterInfo(); Register BasePtr = TRI->getBaseRegister(); - X86AddressMode AM = getAddressFromInstr(&MI, 0); if (TRI->hasBasePointer(*MF) && (BasePtr == X86::RBX || BasePtr == X86::EBX)) { if (!BB->isLiveIn(BasePtr)) @@ -33776,15 +33775,20 @@ X86TargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI, BuildMI(*BB, MI, DL, TII->get(TargetOpcode::COPY), SaveRBX) .addReg(X86::RBX); Register Dst = MF->getRegInfo().createVirtualRegister(&X86::GR64RegClass); - addFullAddress( - BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B_SAVE_RBX), Dst), AM) - .add(MI.getOperand(X86::AddrNumOperands)) - .addReg(SaveRBX); + MachineInstrBuilder MIB = + BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B_SAVE_RBX), Dst); + for (unsigned Idx = 0; Idx < X86::AddrNumOperands; ++Idx) + MIB.add(MI.getOperand(Idx)); + MIB.add(MI.getOperand(X86::AddrNumOperands)); + MIB.addReg(SaveRBX); } else { // Simple case, just copy the virtual register to RBX. BuildMI(*BB, MI, DL, TII->get(TargetOpcode::COPY), X86::RBX) .add(MI.getOperand(X86::AddrNumOperands)); - addFullAddress(BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B)), AM); + MachineInstrBuilder MIB = + BuildMI(*BB, MI, DL, TII->get(X86::LCMPXCHG16B)); + for (unsigned Idx = 0; Idx < X86::AddrNumOperands; ++Idx) + MIB.add(MI.getOperand(Idx)); } MI.eraseFromParent(); return BB;