[llvm] Use range-based for loops with instructions (NFC)
This commit is contained in:
parent
d243cbf8ea
commit
feb40a3a47
|
@ -180,11 +180,9 @@ bool AtomicExpand::runOnFunction(Function &F) {
|
|||
|
||||
// Changing control-flow while iterating through it is a bad idea, so gather a
|
||||
// list of all atomic instructions before we start.
|
||||
for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) {
|
||||
Instruction *I = &*II;
|
||||
if (I->isAtomic() && !isa<FenceInst>(I))
|
||||
AtomicInsts.push_back(I);
|
||||
}
|
||||
for (Instruction &I : instructions(F))
|
||||
if (I.isAtomic() && !isa<FenceInst>(&I))
|
||||
AtomicInsts.push_back(&I);
|
||||
|
||||
bool MadeChange = false;
|
||||
for (auto I : AtomicInsts) {
|
||||
|
|
|
@ -142,12 +142,10 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
|
|||
// Scan the function body for instructions that may read or write memory.
|
||||
bool ReadsMemory = false;
|
||||
bool WritesMemory = false;
|
||||
for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) {
|
||||
Instruction *I = &*II;
|
||||
|
||||
for (Instruction &I : instructions(F)) {
|
||||
// Some instructions can be ignored even if they read or write memory.
|
||||
// Detect these now, skipping to the next instruction if one is found.
|
||||
if (auto *Call = dyn_cast<CallBase>(I)) {
|
||||
if (auto *Call = dyn_cast<CallBase>(&I)) {
|
||||
// Ignore calls to functions in the same SCC, as long as the call sites
|
||||
// don't have operand bundles. Calls with operand bundles are allowed to
|
||||
// have memory effects not described by the memory effects of the call
|
||||
|
@ -187,7 +185,7 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
|
|||
continue;
|
||||
|
||||
MemoryLocation Loc =
|
||||
MemoryLocation::getBeforeOrAfter(Arg, I->getAAMetadata());
|
||||
MemoryLocation::getBeforeOrAfter(Arg, I.getAAMetadata());
|
||||
|
||||
// Skip accesses to local or constant memory as they don't impact the
|
||||
// externally visible mod/ref behavior.
|
||||
|
@ -202,21 +200,21 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
|
|||
ReadsMemory = true;
|
||||
}
|
||||
continue;
|
||||
} else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
|
||||
} else if (LoadInst *LI = dyn_cast<LoadInst>(&I)) {
|
||||
// Ignore non-volatile loads from local memory. (Atomic is okay here.)
|
||||
if (!LI->isVolatile()) {
|
||||
MemoryLocation Loc = MemoryLocation::get(LI);
|
||||
if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
||||
continue;
|
||||
}
|
||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
|
||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(&I)) {
|
||||
// Ignore non-volatile stores to local memory. (Atomic is okay here.)
|
||||
if (!SI->isVolatile()) {
|
||||
MemoryLocation Loc = MemoryLocation::get(SI);
|
||||
if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
||||
continue;
|
||||
}
|
||||
} else if (VAArgInst *VI = dyn_cast<VAArgInst>(I)) {
|
||||
} else if (VAArgInst *VI = dyn_cast<VAArgInst>(&I)) {
|
||||
// Ignore vaargs on local memory.
|
||||
MemoryLocation Loc = MemoryLocation::get(VI);
|
||||
if (AAR.pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
||||
|
@ -227,10 +225,10 @@ static MemoryAccessKind checkFunctionMemoryAccess(Function &F, bool ThisBody,
|
|||
// read or write memory.
|
||||
//
|
||||
// Writes memory, remember that.
|
||||
WritesMemory |= I->mayWriteToMemory();
|
||||
WritesMemory |= I.mayWriteToMemory();
|
||||
|
||||
// If this instruction may read memory, remember that.
|
||||
ReadsMemory |= I->mayReadFromMemory();
|
||||
ReadsMemory |= I.mayReadFromMemory();
|
||||
}
|
||||
|
||||
if (WritesMemory) {
|
||||
|
|
|
@ -56,12 +56,10 @@ static bool runImpl(Function &F) {
|
|||
LLVM_DEBUG(dbgs() << "ObjCARCExpand: Visiting Function: " << F.getName()
|
||||
<< "\n");
|
||||
|
||||
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
|
||||
Instruction *Inst = &*I;
|
||||
for (Instruction &Inst : instructions(&F)) {
|
||||
LLVM_DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << Inst << "\n");
|
||||
|
||||
LLVM_DEBUG(dbgs() << "ObjCARCExpand: Visiting: " << *Inst << "\n");
|
||||
|
||||
switch (GetBasicARCInstKind(Inst)) {
|
||||
switch (GetBasicARCInstKind(&Inst)) {
|
||||
case ARCInstKind::Retain:
|
||||
case ARCInstKind::RetainRV:
|
||||
case ARCInstKind::Autorelease:
|
||||
|
@ -73,12 +71,12 @@ static bool runImpl(Function &F) {
|
|||
// harder. Undo any uses of this optimization that the front-end
|
||||
// emitted here. We'll redo them in the contract pass.
|
||||
Changed = true;
|
||||
Value *Value = cast<CallInst>(Inst)->getArgOperand(0);
|
||||
LLVM_DEBUG(dbgs() << "ObjCARCExpand: Old = " << *Inst
|
||||
Value *Value = cast<CallInst>(&Inst)->getArgOperand(0);
|
||||
LLVM_DEBUG(dbgs() << "ObjCARCExpand: Old = " << Inst
|
||||
<< "\n"
|
||||
" New = "
|
||||
<< *Value << "\n");
|
||||
Inst->replaceAllUsesWith(Value);
|
||||
Inst.replaceAllUsesWith(Value);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -58,11 +58,11 @@ bool PAEval::runOnFunction(Function &F) {
|
|||
for (auto &Arg : F.args())
|
||||
insertIfNamed(Values, &Arg);
|
||||
|
||||
for (auto I = inst_begin(F), E = inst_end(F); I != E; ++I) {
|
||||
insertIfNamed(Values, &*I);
|
||||
for (Instruction &I : instructions(F)) {
|
||||
insertIfNamed(Values, &I);
|
||||
|
||||
for (auto &Op : I->operands())
|
||||
insertIfNamed(Values, Op);
|
||||
for (auto &Op : I.operands())
|
||||
insertIfNamed(Values, Op);
|
||||
}
|
||||
|
||||
ProvenanceAnalysis PA;
|
||||
|
|
Loading…
Reference in New Issue