From fbac64d678060084fdce35371783ad9edd7264f3 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 30 Jun 2016 18:32:12 +0000 Subject: [PATCH] CodeGen: Add the other BuildMI overload for MachineInstr& The change in r274193 missed this variant. llvm-svn: 274259 --- .../include/llvm/CodeGen/MachineInstrBuilder.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h index da0afc320357..37b67aa0cf5c 100644 --- a/llvm/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/llvm/include/llvm/CodeGen/MachineInstrBuilder.h @@ -320,16 +320,20 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, return MachineInstrBuilder(MF, MI); } +inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr &I, + const DebugLoc &DL, + const MCInstrDesc &MCID) { + // Calling the overload for instr_iterator is always correct. However, the + // definition is not available in headers, so inline the check. + if (I.isInsideBundle()) + return BuildMI(BB, MachineBasicBlock::instr_iterator(I), DL, MCID); + return BuildMI(BB, MachineBasicBlock::iterator(I), DL, MCID); +} + inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB, MachineInstr *I, const DebugLoc &DL, const MCInstrDesc &MCID) { - if (I->isInsideBundle()) { - MachineBasicBlock::instr_iterator MII(I); - return BuildMI(BB, MII, DL, MCID); - } - - MachineBasicBlock::iterator MII = I; - return BuildMI(BB, MII, DL, MCID); + return BuildMI(BB, *I, DL, MCID); } /// This version of the builder inserts the newly-built instruction at the end