Skip to content

Commit e921088

Browse files
committedJul 27, 2016
XCore: Avoid implicit iterator conversions, NFC
Avoid implicit conversions from MachineInstrBundleIterator to MachineInstr*, mainly by preferring MachineInstr& over MachineInstr*. llvm-svn: 276899
1 parent 9155354 commit e921088

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed
 

‎llvm/lib/Target/XCore/XCoreFrameLowering.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ MachineBasicBlock::iterator XCoreFrameLowering::eliminateCallFramePseudoInstr(
490490
if (!hasReservedCallFrame(MF)) {
491491
// Turn the adjcallstackdown instruction into 'extsp <amt>' and the
492492
// adjcallstackup instruction into 'ldaw sp, sp[<amt>]'
493-
MachineInstr *Old = I;
494-
uint64_t Amount = Old->getOperand(0).getImm();
493+
MachineInstr &Old = *I;
494+
uint64_t Amount = Old.getOperand(0).getImm();
495495
if (Amount != 0) {
496496
// We need to keep the stack aligned properly. To do this, we round the
497497
// amount of space needed for the outgoing arguments up to the next
@@ -513,15 +513,14 @@ MachineBasicBlock::iterator XCoreFrameLowering::eliminateCallFramePseudoInstr(
513513
}
514514

515515
MachineInstr *New;
516-
if (Old->getOpcode() == XCore::ADJCALLSTACKDOWN) {
516+
if (Old.getOpcode() == XCore::ADJCALLSTACKDOWN) {
517517
int Opcode = isU6 ? XCore::EXTSP_u6 : XCore::EXTSP_lu6;
518-
New=BuildMI(MF, Old->getDebugLoc(), TII.get(Opcode))
519-
.addImm(Amount);
518+
New = BuildMI(MF, Old.getDebugLoc(), TII.get(Opcode)).addImm(Amount);
520519
} else {
521-
assert(Old->getOpcode() == XCore::ADJCALLSTACKUP);
520+
assert(Old.getOpcode() == XCore::ADJCALLSTACKUP);
522521
int Opcode = isU6 ? XCore::LDAWSP_ru6 : XCore::LDAWSP_lru6;
523-
New=BuildMI(MF, Old->getDebugLoc(), TII.get(Opcode), XCore::SP)
524-
.addImm(Amount);
522+
New = BuildMI(MF, Old.getDebugLoc(), TII.get(Opcode), XCore::SP)
523+
.addImm(Amount);
525524
}
526525

527526
// Replace the pseudo instruction with a new instruction...

‎llvm/lib/Target/XCore/XCoreFrameToArgsOffsetElim.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ bool XCoreFTAOElim::runOnMachineFunction(MachineFunction &MF) {
5555
for (MachineBasicBlock::iterator MBBI = MBB.begin(), EE = MBB.end();
5656
MBBI != EE; ++MBBI) {
5757
if (MBBI->getOpcode() == XCore::FRAME_TO_ARGS_OFFSET) {
58-
MachineInstr *OldInst = MBBI;
59-
unsigned Reg = OldInst->getOperand(0).getReg();
58+
MachineInstr &OldInst = *MBBI;
59+
unsigned Reg = OldInst.getOperand(0).getReg();
6060
MBBI = TII.loadImmediate(MBB, MBBI, Reg, StackSize);
61-
OldInst->eraseFromParent();
61+
OldInst.eraseFromParent();
6262
}
6363
}
6464
}

‎llvm/lib/Target/XCore/XCoreInstrInfo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ bool XCoreInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
201201
return false;
202202

203203
// Get the last instruction in the block.
204-
MachineInstr *LastInst = I;
205-
204+
MachineInstr *LastInst = &*I;
205+
206206
// If there is only one terminator instruction, process it.
207207
if (I == MBB.begin() || !isUnpredicatedTerminator(*--I)) {
208208
if (IsBRU(LastInst->getOpcode())) {
@@ -224,7 +224,7 @@ bool XCoreInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
224224
}
225225

226226
// Get the instruction before it if it's a terminator.
227-
MachineInstr *SecondLastInst = I;
227+
MachineInstr *SecondLastInst = &*I;
228228

229229
// If there are three terminators, we don't know what sort of block this is.
230230
if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(*--I))

0 commit comments

Comments
 (0)
Please sign in to comment.