[IR] Use range-based for loops (NFC)

This commit is contained in:
Kazu Hirata 2021-02-28 10:59:23 -08:00
parent 87360d6ff7
commit b4bed1cb24
3 changed files with 14 additions and 21 deletions

View File

@ -335,8 +335,8 @@ public:
/// Initialize available analysis information.
void initializeAnalysisInfo() {
AvailableAnalysis.clear();
for (unsigned i = 0; i < PMT_Last; ++i)
InheritedAnalysis[i] = nullptr;
for (auto &IA : InheritedAnalysis)
IA = nullptr;
}
// Return true if P preserves high level analysis used by other
@ -392,9 +392,8 @@ public:
// Collect AvailableAnalysis from all the active Pass Managers.
void populateInheritedAnalysis(PMStack &PMS) {
unsigned Index = 0;
for (PMStack::iterator I = PMS.begin(), E = PMS.end();
I != E; ++I)
InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
for (PMDataManager *PMDM : PMS)
InheritedAnalysis[Index++] = PMDM->getAvailableAnalysis();
}
/// Set the initial size of the module if the user has specified that they

View File

@ -1088,9 +1088,8 @@ int SlotTracker::processIndex() {
// Start numbering the TypeIds after the GUIDs.
TypeIdNext = GUIDNext;
for (auto TidIter = TheIndex->typeIds().begin();
TidIter != TheIndex->typeIds().end(); TidIter++)
CreateTypeIdSlot(TidIter->second.first);
for (const auto &TID : TheIndex->typeIds())
CreateTypeIdSlot(TID.second.first);
ST_DEBUG("end processIndex!\n");
return TypeIdNext;
@ -4028,8 +4027,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(I.getOperand(0), true); Out << ", ";
writeOperand(I.getOperand(1), true);
for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
Out << ", " << *i;
for (unsigned i : IVI->indices())
Out << ", " << i;
} else if (const LandingPadInst *LPI = dyn_cast<LandingPadInst>(&I)) {
Out << ' ';
TypePrinter.print(I.getType(), Out);
@ -4431,9 +4430,8 @@ void AssemblyWriter::writeAllAttributeGroups() {
std::vector<std::pair<AttributeSet, unsigned>> asVec;
asVec.resize(Machine.as_size());
for (SlotTracker::as_iterator I = Machine.as_begin(), E = Machine.as_end();
I != E; ++I)
asVec[I->second] = *I;
for (auto &I : llvm::make_range(Machine.as_begin(), Machine.as_end()))
asVec[I.second] = I;
for (const auto &I : asVec)
Out << "attributes #" << I.second << " = { "

View File

@ -353,16 +353,12 @@ bool llvm::stripDebugInfo(Function &F) {
bool llvm::StripDebugInfo(Module &M) {
bool Changed = false;
for (Module::named_metadata_iterator NMI = M.named_metadata_begin(),
NME = M.named_metadata_end(); NMI != NME;) {
NamedMDNode *NMD = &*NMI;
++NMI;
for (NamedMDNode &NMD : llvm::make_early_inc_range(M.named_metadata())) {
// We're stripping debug info, and without them, coverage information
// doesn't quite make sense.
if (NMD->getName().startswith("llvm.dbg.") ||
NMD->getName() == "llvm.gcov") {
NMD->eraseFromParent();
if (NMD.getName().startswith("llvm.dbg.") ||
NMD.getName() == "llvm.gcov") {
NMD.eraseFromParent();
Changed = true;
}
}