1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[Transforms/Instrumentation] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata 2021-02-05 21:02:07 -08:00
parent c92524272b
commit fd7d8e9304
4 changed files with 22 additions and 24 deletions

View File

@ -122,10 +122,10 @@ public:
static const uint32_t CriticalEdgeMultiplier = 1000;
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
Instruction *TI = BB->getTerminator();
for (BasicBlock &BB : F) {
Instruction *TI = BB.getTerminator();
uint64_t BBWeight =
(BFI != nullptr ? BFI->getBlockFreq(&*BB).getFrequency() : 2);
(BFI != nullptr ? BFI->getBlockFreq(&BB).getFrequency() : 2);
uint64_t Weight = 2;
if (int successors = TI->getNumSuccessors()) {
for (int i = 0; i != successors; ++i) {
@ -139,16 +139,16 @@ public:
scaleFactor = UINT64_MAX;
}
if (BPI != nullptr)
Weight = BPI->getEdgeProbability(&*BB, TargetBB).scale(scaleFactor);
Weight = BPI->getEdgeProbability(&BB, TargetBB).scale(scaleFactor);
if (Weight == 0)
Weight++;
auto *E = &addEdge(&*BB, TargetBB, Weight);
auto *E = &addEdge(&BB, TargetBB, Weight);
E->IsCritical = Critical;
LLVM_DEBUG(dbgs() << " Edge: from " << BB->getName() << " to "
LLVM_DEBUG(dbgs() << " Edge: from " << BB.getName() << " to "
<< TargetBB->getName() << " w=" << Weight << "\n");
// Keep track of entry/exit edges:
if (&*BB == Entry) {
if (&BB == Entry) {
if (Weight > MaxEntryOutWeight) {
MaxEntryOutWeight = Weight;
EntryOutgoing = E;
@ -165,12 +165,12 @@ public:
}
} else {
ExitBlockFound = true;
Edge *ExitO = &addEdge(&*BB, nullptr, BBWeight);
Edge *ExitO = &addEdge(&BB, nullptr, BBWeight);
if (BBWeight > MaxExitOutWeight) {
MaxExitOutWeight = BBWeight;
ExitOutgoing = ExitO;
}
LLVM_DEBUG(dbgs() << " Edge: from " << BB->getName() << " to fake exit"
LLVM_DEBUG(dbgs() << " Edge: from " << BB.getName() << " to fake exit"
<< " w = " << BBWeight << "\n");
}
}

View File

@ -2188,8 +2188,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
if (!MS.TrackOrigins) return;
IRBuilder<> IRB(&I);
OriginCombiner OC(this, IRB);
for (Instruction::op_iterator OI = I.op_begin(); OI != I.op_end(); ++OI)
OC.Add(OI->get());
for (Use &Op : I.operands())
OC.Add(Op.get());
OC.Done(&I);
}
@ -2239,8 +2239,8 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
void handleShadowOr(Instruction &I) {
IRBuilder<> IRB(&I);
ShadowAndOriginCombiner SC(this, IRB);
for (Instruction::op_iterator OI = I.op_begin(); OI != I.op_end(); ++OI)
SC.Add(OI->get());
for (Use &Op : I.operands())
SC.Add(Op.get());
SC.Done(&I);
}
@ -4049,8 +4049,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
NumRetOutputs = 1;
}
InlineAsm::ConstraintInfoVector Constraints = IA->ParseConstraints();
for (size_t i = 0, n = Constraints.size(); i < n; i++) {
InlineAsm::ConstraintInfo Info = Constraints[i];
for (const InlineAsm::ConstraintInfo &Info : Constraints) {
switch (Info.Type) {
case InlineAsm::isOutput:
NumOutputs++;

View File

@ -1465,8 +1465,8 @@ void PGOUseFunc::setBranchWeights() {
}
static bool isIndirectBrTarget(BasicBlock *BB) {
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
if (isa<IndirectBrInst>((*PI)->getTerminator()))
for (BasicBlock *Pred : predecessors(BB)) {
if (isa<IndirectBrInst>(Pred->getTerminator()))
return true;
}
return false;
@ -2124,14 +2124,13 @@ template <> struct DOTGraphTraits<PGOUseFunc *> : DefaultDOTGraphTraits {
if (!PGOInstrSelect)
return Result;
for (auto BI = Node->begin(); BI != Node->end(); ++BI) {
auto *I = &*BI;
if (!isa<SelectInst>(I))
for (const Instruction &I : *Node) {
if (!isa<SelectInst>(&I))
continue;
// Display scaled counts for SELECT instruction:
OS << "SELECT : { T = ";
uint64_t TC, FC;
bool HasProf = I->extractProfMetadata(TC, FC);
bool HasProf = I.extractProfMetadata(TC, FC);
if (!HasProf)
OS << "Unknown, F = Unknown }\\l";
else

View File

@ -833,10 +833,10 @@ void ModuleSanitizerCoverage::InjectTraceForGep(
Function &, ArrayRef<GetElementPtrInst *> GepTraceTargets) {
for (auto GEP : GepTraceTargets) {
IRBuilder<> IRB(GEP);
for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I)
if (!isa<ConstantInt>(*I) && (*I)->getType()->isIntegerTy())
for (Use &Idx : GEP->indices())
if (!isa<ConstantInt>(Idx) && Idx->getType()->isIntegerTy())
IRB.CreateCall(SanCovTraceGepFunction,
{IRB.CreateIntCast(*I, IntptrTy, true)});
{IRB.CreateIntCast(Idx, IntptrTy, true)});
}
}