[llvm] r250144 - BitcodeWriter: Stop using implicit ilist iterator conversion, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 12 20:26:19 PDT 2015
Author: dexonsmith
Date: Mon Oct 12 22:26:19 2015
New Revision: 250144
URL: http://llvm.org/viewvc/llvm-project?rev=250144&view=rev
Log:
BitcodeWriter: Stop using implicit ilist iterator conversion, NFC
Now LLVMBitWriter compiles without implicit ilist iterator conversions.
In these cases, the cleanest thing was to switch to range-based for
loops. Since there wasn't much noise I converted sub-loops and parent
loops as a drive-by.
Modified:
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=250144&r1=250143&r2=250144&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Oct 12 22:26:19 2015
@@ -1350,16 +1350,15 @@ static void WriteMetadataAttachment(cons
Record.clear();
}
- for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
- I != E; ++I) {
+ for (const BasicBlock &BB : F)
+ for (const Instruction &I : BB) {
MDs.clear();
- I->getAllMetadataOtherThanDebugLoc(MDs);
+ I.getAllMetadataOtherThanDebugLoc(MDs);
// If no metadata, ignore instruction.
if (MDs.empty()) continue;
- Record.push_back(VE.getInstructionID(I));
+ Record.push_back(VE.getInstructionID(&I));
for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
Record.push_back(MDs[i].first);
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=250144&r1=250143&r2=250144&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Mon Oct 12 22:26:19 2015
@@ -512,10 +512,8 @@ void ValueEnumerator::EnumerateValueSymb
/// Insert all of the values referenced by named metadata in the specified
/// module.
void ValueEnumerator::EnumerateNamedMetadata(const Module &M) {
- for (Module::const_named_metadata_iterator I = M.named_metadata_begin(),
- E = M.named_metadata_end();
- I != E; ++I)
- EnumerateNamedMDNode(I);
+ for (const auto &I : M.named_metadata())
+ EnumerateNamedMDNode(&I);
}
void ValueEnumerator::EnumerateNamedMDNode(const NamedMDNode *MD) {
@@ -729,23 +727,20 @@ void ValueEnumerator::incorporateFunctio
NumModuleMDs = MDs.size();
// Adding function arguments to the value table.
- for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end();
- I != E; ++I)
- EnumerateValue(I);
+ for (const auto &I : F.args())
+ EnumerateValue(&I);
FirstFuncConstantID = Values.size();
// Add all function-level constants to the value table.
- for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
- for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
- OI != E; ++OI) {
- if ((isa<Constant>(*OI) && !isa<GlobalValue>(*OI)) ||
- isa<InlineAsm>(*OI))
- EnumerateValue(*OI);
+ for (const BasicBlock &BB : F) {
+ for (const Instruction &I : BB)
+ for (const Use &OI : I.operands()) {
+ if ((isa<Constant>(OI) && !isa<GlobalValue>(OI)) || isa<InlineAsm>(OI))
+ EnumerateValue(OI);
}
- BasicBlocks.push_back(BB);
- ValueMap[BB] = BasicBlocks.size();
+ BasicBlocks.push_back(&BB);
+ ValueMap[&BB] = BasicBlocks.size();
}
// Optimize the constant layout.
@@ -759,18 +754,17 @@ void ValueEnumerator::incorporateFunctio
SmallVector<LocalAsMetadata *, 8> FnLocalMDVector;
// Add all of the instructions.
- for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
- for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
- for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
- OI != E; ++OI) {
- if (auto *MD = dyn_cast<MetadataAsValue>(&*OI))
+ for (const BasicBlock &BB : F) {
+ for (const Instruction &I : BB) {
+ for (const Use &OI : I.operands()) {
+ if (auto *MD = dyn_cast<MetadataAsValue>(&OI))
if (auto *Local = dyn_cast<LocalAsMetadata>(MD->getMetadata()))
// Enumerate metadata after the instructions they might refer to.
FnLocalMDVector.push_back(Local);
}
- if (!I->getType()->isVoidTy())
- EnumerateValue(I);
+ if (!I.getType()->isVoidTy())
+ EnumerateValue(&I);
}
}
@@ -797,8 +791,8 @@ void ValueEnumerator::purgeFunction() {
static void IncorporateFunctionInfoGlobalBBIDs(const Function *F,
DenseMap<const BasicBlock*, unsigned> &IDMap) {
unsigned Counter = 0;
- for (Function::const_iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
- IDMap[BB] = ++Counter;
+ for (const BasicBlock &BB : *F)
+ IDMap[&BB] = ++Counter;
}
/// getGlobalBasicBlockID - This returns the function-specific ID for the
More information about the llvm-commits
mailing list