Work around bugs in MSVC "14" CTP 3's conversion logic

It appears to ignore or find ambiguous MachineInstrBuilder's conversion
operators that allow conversion to MachineInstr* and
MachineBasicBlock::bundle_iterator.

As a workaround, add an explicit way to get the MachineInstr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221017 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner 2014-10-31 23:19:46 +00:00
parent 9f86b43215
commit e1a4787d5d
6 changed files with 17 additions and 8 deletions

View File

@ -58,6 +58,10 @@ public:
MachineInstr *operator->() const { return MI; }
operator MachineBasicBlock::iterator() const { return MI; }
/// If conversion operators fail, use this method to get the MachineInstr
/// explicitly.
MachineInstr *getInstr() const { return MI; }
/// addReg - Add a new virtual register operand...
///
const

View File

@ -188,7 +188,7 @@ bool Thumb2ITBlockPass::InsertITInstructions(MachineBasicBlock &MBB) {
true/*isImp*/, false/*isKill*/));
MachineInstr *LastITMI = MI;
MachineBasicBlock::iterator InsertPos = MIB;
MachineBasicBlock::iterator InsertPos = MIB.getInstr();
++MBBI;
// Form IT block.

View File

@ -283,7 +283,7 @@ MachineBasicBlock::iterator SILoadStoreOptimizer::mergeRead2Pair(
LIS->getInterval(DestReg); // Create new LI
DEBUG(dbgs() << "Inserted read2: " << *Read2 << '\n');
return Read2;
return Read2.getInstr();
}
MachineBasicBlock::iterator SILoadStoreOptimizer::mergeWrite2Pair(
@ -347,7 +347,7 @@ MachineBasicBlock::iterator SILoadStoreOptimizer::mergeWrite2Pair(
LIS->repairIntervalsInRange(MBB, Write2, Write2, OrigRegs);
DEBUG(dbgs() << "Inserted write2 inst: " << *Write2 << '\n');
return Write2;
return Write2.getInstr();
}
// Scan through looking for adjacent LDS operations with constant offsets from

View File

@ -834,7 +834,9 @@ FPS::freeStackSlotBefore(MachineBasicBlock::iterator I, unsigned FPRegNo) {
RegMap[TopReg] = OldSlot;
RegMap[FPRegNo] = ~0;
Stack[--StackTop] = ~0;
return BuildMI(*MBB, I, DebugLoc(), TII->get(X86::ST_FPrr)).addReg(STReg);
return BuildMI(*MBB, I, DebugLoc(), TII->get(X86::ST_FPrr))
.addReg(STReg)
.getInstr();
}
/// adjustLiveRegs - Kill and revive registers such that exactly the FP

View File

@ -3992,7 +3992,7 @@ static void expandLoadStackGuard(MachineInstrBuilder &MIB,
unsigned Flag = MachineMemOperand::MOLoad | MachineMemOperand::MOInvariant;
MachineMemOperand *MMO = MBB.getParent()->
getMachineMemOperand(MachinePointerInfo::getGOT(), Flag, 8, 8);
MachineBasicBlock::iterator I = MIB;
MachineBasicBlock::iterator I = MIB.getInstr();
BuildMI(MBB, I, DL, TII.get(X86::MOV64rm), Reg).addReg(X86::RIP).addImm(1)
.addReg(0).addGlobalAddress(GV, 0, X86II::MO_GOTPCREL).addReg(0)

View File

@ -446,16 +446,19 @@ MachineBasicBlock::iterator XCoreInstrInfo::loadImmediate(
dl = MI->getDebugLoc();
if (isImmMskBitp(Value)) {
int N = Log2_32(Value) + 1;
return BuildMI(MBB, MI, dl, get(XCore::MKMSK_rus), Reg).addImm(N);
return BuildMI(MBB, MI, dl, get(XCore::MKMSK_rus), Reg)
.addImm(N)
.getInstr();
}
if (isImmU16(Value)) {
int Opcode = isImmU6(Value) ? XCore::LDC_ru6 : XCore::LDC_lru6;
return BuildMI(MBB, MI, dl, get(Opcode), Reg).addImm(Value);
return BuildMI(MBB, MI, dl, get(Opcode), Reg).addImm(Value).getInstr();
}
MachineConstantPool *ConstantPool = MBB.getParent()->getConstantPool();
const Constant *C = ConstantInt::get(
Type::getInt32Ty(MBB.getParent()->getFunction()->getContext()), Value);
unsigned Idx = ConstantPool->getConstantPoolIndex(C, 4);
return BuildMI(MBB, MI, dl, get(XCore::LDWCP_lru6), Reg)
.addConstantPoolIndex(Idx);
.addConstantPoolIndex(Idx)
.getInstr();
}