Skip to content

Commit 5ae5939

Browse files
committed
CodeGen: Remove more ilist iterator implicit conversions, NFC
llvm-svn: 249879
1 parent 6c64aeb commit 5ae5939

7 files changed

+27
-28
lines changed

llvm/lib/CodeGen/IfConversion.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ bool IfConverter::ReverseBranchCondition(BBInfo &BBI) {
462462
/// getNextBlock - Returns the next block in the function blocks ordering. If
463463
/// it is the end, returns NULL.
464464
static inline MachineBasicBlock *getNextBlock(MachineBasicBlock *BB) {
465-
MachineFunction::iterator I = BB;
465+
MachineFunction::iterator I = BB->getIterator();
466466
MachineFunction::iterator E = BB->getParent()->end();
467467
if (++I == E)
468468
return nullptr;
469-
return I;
469+
return &*I;
470470
}
471471

472472
/// ValidSimple - Returns true if the 'true' block (along with its
@@ -530,10 +530,10 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI,
530530

531531
MachineBasicBlock *TExit = FalseBranch ? TrueBBI.FalseBB : TrueBBI.TrueBB;
532532
if (!TExit && blockAlwaysFallThrough(TrueBBI)) {
533-
MachineFunction::iterator I = TrueBBI.BB;
533+
MachineFunction::iterator I = TrueBBI.BB->getIterator();
534534
if (++I == TrueBBI.BB->getParent()->end())
535535
return false;
536-
TExit = I;
536+
TExit = &*I;
537537
}
538538
return TExit && TExit == FalseBBI.BB;
539539
}
@@ -948,10 +948,8 @@ void IfConverter::AnalyzeBlock(MachineBasicBlock *MBB,
948948
/// candidates.
949949
void IfConverter::AnalyzeBlocks(MachineFunction &MF,
950950
std::vector<IfcvtToken*> &Tokens) {
951-
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
952-
MachineBasicBlock *BB = I;
953-
AnalyzeBlock(BB, Tokens);
954-
}
951+
for (auto &BB : MF)
952+
AnalyzeBlock(&BB, Tokens);
955953

956954
// Sort to favor more complex ifcvt scheme.
957955
std::stable_sort(Tokens.begin(), Tokens.end(), IfcvtTokenCmp);
@@ -961,14 +959,14 @@ void IfConverter::AnalyzeBlocks(MachineFunction &MF,
961959
/// that all the intervening blocks are empty (given BB can fall through to its
962960
/// next block).
963961
static bool canFallThroughTo(MachineBasicBlock *BB, MachineBasicBlock *ToBB) {
964-
MachineFunction::iterator PI = BB;
962+
MachineFunction::iterator PI = BB->getIterator();
965963
MachineFunction::iterator I = std::next(PI);
966-
MachineFunction::iterator TI = ToBB;
964+
MachineFunction::iterator TI = ToBB->getIterator();
967965
MachineFunction::iterator E = BB->getParent()->end();
968966
while (I != TI) {
969967
// Check isSuccessor to avoid case where the next block is empty, but
970968
// it's not a successor.
971-
if (I == E || !I->empty() || !PI->isSuccessor(I))
969+
if (I == E || !I->empty() || !PI->isSuccessor(&*I))
972970
return false;
973971
PI = I++;
974972
}

llvm/lib/CodeGen/InterferenceCache.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void InterferenceCache::Entry::update(unsigned MBBNum) {
144144
PrevPos = Start;
145145
}
146146

147-
MachineFunction::const_iterator MFI = MF->getBlockNumbered(MBBNum);
147+
MachineFunction::const_iterator MFI =
148+
MF->getBlockNumbered(MBBNum)->getIterator();
148149
BlockInterference *BI = &Blocks[MBBNum];
149150
ArrayRef<SlotIndex> RegMaskSlots;
150151
ArrayRef<const uint32_t*> RegMaskBits;

llvm/lib/CodeGen/IntrinsicLowering.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static CallInst *ReplaceCallWith(const char *NewFn, CallInst *CI,
7575
Constant* FCache = M->getOrInsertFunction(NewFn,
7676
FunctionType::get(RetTy, ParamTys, false));
7777

78-
IRBuilder<> Builder(CI->getParent(), CI);
78+
IRBuilder<> Builder(CI->getParent(), CI->getIterator());
7979
SmallVector<Value *, 8> Args(ArgBegin, ArgEnd);
8080
CallInst *NewCI = Builder.CreateCall(FCache, Args);
8181
NewCI->setName(CI->getName());
@@ -167,8 +167,8 @@ static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
167167
assert(V->getType()->isIntegerTy() && "Can't bswap a non-integer type!");
168168

169169
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
170-
171-
IRBuilder<> Builder(IP->getParent(), IP);
170+
171+
IRBuilder<> Builder(IP);
172172

173173
switch(BitSize) {
174174
default: llvm_unreachable("Unhandled type size of value to byteswap!");
@@ -268,7 +268,7 @@ static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) {
268268
0x0000FFFF0000FFFFULL, 0x00000000FFFFFFFFULL
269269
};
270270

271-
IRBuilder<> Builder(IP->getParent(), IP);
271+
IRBuilder<> Builder(IP);
272272

273273
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
274274
unsigned WordSize = (BitSize + 63) / 64;
@@ -301,7 +301,7 @@ static Value *LowerCTPOP(LLVMContext &Context, Value *V, Instruction *IP) {
301301
/// instruction IP.
302302
static Value *LowerCTLZ(LLVMContext &Context, Value *V, Instruction *IP) {
303303

304-
IRBuilder<> Builder(IP->getParent(), IP);
304+
IRBuilder<> Builder(IP);
305305

306306
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
307307
for (unsigned i = 1; i < BitSize; i <<= 1) {
@@ -338,7 +338,7 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
338338
}
339339

340340
void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
341-
IRBuilder<> Builder(CI->getParent(), CI);
341+
IRBuilder<> Builder(CI);
342342
LLVMContext &Context = CI->getContext();
343343

344344
const Function *Callee = CI->getCalledFunction();

llvm/lib/CodeGen/LiveDebugVariables.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ bool LDVImpl::collectDebugValues(MachineFunction &mf) {
512512
bool Changed = false;
513513
for (MachineFunction::iterator MFI = mf.begin(), MFE = mf.end(); MFI != MFE;
514514
++MFI) {
515-
MachineBasicBlock *MBB = MFI;
515+
MachineBasicBlock *MBB = &*MFI;
516516
for (MachineBasicBlock::iterator MBBI = MBB->begin(), MBBE = MBB->end();
517517
MBBI != MBBE;) {
518518
if (!MBBI->isDebugValue()) {
@@ -1004,21 +1004,21 @@ void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS,
10041004
SlotIndex Stop = I.stop();
10051005
unsigned LocNo = I.value();
10061006
DEBUG(dbgs() << "\t[" << Start << ';' << Stop << "):" << LocNo);
1007-
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start);
1008-
SlotIndex MBBEnd = LIS.getMBBEndIdx(MBB);
1007+
MachineFunction::iterator MBB = LIS.getMBBFromIndex(Start)->getIterator();
1008+
SlotIndex MBBEnd = LIS.getMBBEndIdx(&*MBB);
10091009

10101010
DEBUG(dbgs() << " BB#" << MBB->getNumber() << '-' << MBBEnd);
1011-
insertDebugValue(MBB, Start, LocNo, LIS, TII);
1011+
insertDebugValue(&*MBB, Start, LocNo, LIS, TII);
10121012
// This interval may span multiple basic blocks.
10131013
// Insert a DBG_VALUE into each one.
10141014
while(Stop > MBBEnd) {
10151015
// Move to the next block.
10161016
Start = MBBEnd;
10171017
if (++MBB == MFEnd)
10181018
break;
1019-
MBBEnd = LIS.getMBBEndIdx(MBB);
1019+
MBBEnd = LIS.getMBBEndIdx(&*MBB);
10201020
DEBUG(dbgs() << " BB#" << MBB->getNumber() << '-' << MBBEnd);
1021-
insertDebugValue(MBB, Start, LocNo, LIS, TII);
1021+
insertDebugValue(&*MBB, Start, LocNo, LIS, TII);
10221022
}
10231023
DEBUG(dbgs() << '\n');
10241024
if (MBB == MFEnd)

llvm/lib/CodeGen/LiveIntervalAnalysis.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void LiveIntervals::computeRegMasks() {
224224
// Find all instructions with regmask operands.
225225
for (MachineFunction::iterator MBBI = MF->begin(), E = MF->end();
226226
MBBI != E; ++MBBI) {
227-
MachineBasicBlock *MBB = MBBI;
227+
MachineBasicBlock *MBB = &*MBBI;
228228
std::pair<unsigned, unsigned> &RMB = RegMaskBlocks[MBB->getNumber()];
229229
RMB.first = RegMaskSlots.size();
230230
for (MachineBasicBlock::iterator MI = MBB->begin(), ME = MBB->end();
@@ -302,7 +302,7 @@ void LiveIntervals::computeLiveInRegUnits() {
302302
// Check all basic blocks for live-ins.
303303
for (MachineFunction::const_iterator MFI = MF->begin(), MFE = MF->end();
304304
MFI != MFE; ++MFI) {
305-
const MachineBasicBlock *MBB = MFI;
305+
const MachineBasicBlock *MBB = &*MFI;
306306

307307
// We only care about ABI blocks: Entry + landing pads.
308308
if ((MFI != MF->begin() && !MBB->isEHPad()) || MBB->livein_empty())

llvm/lib/CodeGen/LiveVariables.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &mf) {
637637
// function. This guarantees that we will see the definition of a virtual
638638
// register before its uses due to dominance properties of SSA (except for PHI
639639
// nodes, which are treated as a special case).
640-
MachineBasicBlock *Entry = MF->begin();
640+
MachineBasicBlock *Entry = &MF->front();
641641
SmallPtrSet<MachineBasicBlock*,16> Visited;
642642

643643
for (MachineBasicBlock *MBB : depth_first_ext(Entry, Visited)) {

llvm/lib/CodeGen/LocalStackSlotAllocation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ bool LocalStackSlotPass::insertFrameReferenceRegisters(MachineFunction &Fn) {
325325
// Sort the frame references by local offset
326326
array_pod_sort(FrameReferenceInsns.begin(), FrameReferenceInsns.end());
327327

328-
MachineBasicBlock *Entry = Fn.begin();
328+
MachineBasicBlock *Entry = &Fn.front();
329329

330330
unsigned BaseReg = 0;
331331
int64_t BaseOffset = 0;

0 commit comments

Comments
 (0)