[llvm] r207928 - X86: further range-loopify AsmPrinter
Saleem Abdulrasool
compnerd at compnerd.org
Sat May 3 18:54:17 PDT 2014
Author: compnerd
Date: Sat May 3 20:54:17 2014
New Revision: 207928
URL: http://llvm.org/viewvc/llvm-project?rev=207928&view=rev
Log:
X86: further range-loopify AsmPrinter
Use more range loops in the X86AsmPrinter. NFC.
Modified:
llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
Modified: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp?rev=207928&r1=207927&r2=207928&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp Sat May 3 20:54:17 2014
@@ -595,11 +595,11 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
5, SectionKind::getMetadata());
OutStreamer.SwitchSection(TheSection);
- for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
+ for (const auto &Stub : Stubs) {
// L_foo$stub:
- OutStreamer.EmitLabel(Stubs[i].first);
+ OutStreamer.EmitLabel(Stub.first);
// .indirect_symbol _foo
- OutStreamer.EmitSymbolAttribute(Stubs[i].second.getPointer(),
+ OutStreamer.EmitSymbolAttribute(Stub.second.getPointer(),
MCSA_IndirectSymbol);
// hlt; hlt; hlt; hlt; hlt hlt = 0xf4.
const char HltInsts[] = "\xf4\xf4\xf4\xf4\xf4";
@@ -661,18 +661,16 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
// Necessary for dllexport support
std::vector<const MCSymbol*> DLLExportedFns, DLLExportedGlobals;
- for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (I->hasDLLExportStorageClass())
- DLLExportedFns.push_back(getSymbol(I));
-
- for (Module::const_global_iterator I = M.global_begin(),
- E = M.global_end(); I != E; ++I)
- if (I->hasDLLExportStorageClass())
- DLLExportedGlobals.push_back(getSymbol(I));
-
- for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
- I != E; ++I) {
- const GlobalValue *GV = I;
+ for (const auto &Function : M)
+ if (Function.hasDLLExportStorageClass())
+ DLLExportedFns.push_back(getSymbol(&Function));
+
+ for (const auto &Global : M.globals())
+ if (Global.hasDLLExportStorageClass())
+ DLLExportedGlobals.push_back(getSymbol(&Global));
+
+ for (const auto &Alias : M.aliases()) {
+ const GlobalValue *GV = &Alias;
if (!GV->hasDLLExportStorageClass())
continue;
@@ -680,9 +678,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
GV = A->getAliasedGlobal();
if (isa<Function>(GV))
- DLLExportedFns.push_back(getSymbol(I));
+ DLLExportedFns.push_back(getSymbol(&Alias));
else if (isa<GlobalVariable>(GV))
- DLLExportedGlobals.push_back(getSymbol(I));
+ DLLExportedGlobals.push_back(getSymbol(&Alias));
}
// Output linker support code for dllexported globals on windows.
@@ -711,9 +709,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Mod
OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
const DataLayout *TD = TM.getDataLayout();
- for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
- OutStreamer.EmitLabel(Stubs[i].first);
- OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(),
+ for (const auto &Stub : Stubs) {
+ OutStreamer.EmitLabel(Stub.first);
+ OutStreamer.EmitSymbolValue(Stub.second.getPointer(),
TD->getPointerSize());
}
Stubs.clear();
More information about the llvm-commits
mailing list