summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-07 21:39:48 +0000
committerChris Lattner <sabre@nondot.org>2002-08-07 21:39:48 +0000
commit637ed869e60503f433f8138012d98ed3474e815e (patch)
tree2fdab6f53de21457eb6380c74bd28504ad3223b1 /lib
parent075f028b774c4d16b35a9e897d7b331eb8298e40 (diff)
downloadexternal_llvm-637ed869e60503f433f8138012d98ed3474e815e.zip
external_llvm-637ed869e60503f433f8138012d98ed3474e815e.tar.gz
external_llvm-637ed869e60503f433f8138012d98ed3474e815e.tar.bz2
Merge three loops into one.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3259 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/SparcV9/SparcV9AsmPrinter.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index e58a0c2..c5adac2 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -777,32 +777,27 @@ void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module &M) {
hash_set<const Constant*> moduleConstants;
FoldConstants(M, moduleConstants);
- // Now, emit the three data sections separately; the cost of I/O should
- // make up for the cost of extra passes over the globals list!
-
- // Section 1 : Read-only data section (implies initialized)
+ // Output constants spilled to memory
enterSection(AsmPrinter::ReadOnlyData);
- for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
- if (GI->hasInitializer() && GI->isConstant())
- printGlobalVariable(GI);
-
- for (hash_set<const Constant*>::const_iterator
- I = moduleConstants.begin(),
+ for (hash_set<const Constant*>::const_iterator I = moduleConstants.begin(),
E = moduleConstants.end(); I != E; ++I)
printConstant(*I);
-
- // Section 2 : Initialized read-write data section
- enterSection(AsmPrinter::InitRWData);
- for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
- if (GI->hasInitializer() && !GI->isConstant())
- printGlobalVariable(GI);
-
- // Section 3 : Uninitialized read-write data section
- enterSection(AsmPrinter::UninitRWData);
- for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
- if (!GI->hasInitializer())
- printGlobalVariable(GI);
-
+
+ // Output global variables...
+ for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI) {
+ if (GI->hasInitializer() && GI->isConstant()) {
+ enterSection(AsmPrinter::ReadOnlyData); // read-only, initialized data
+ } else if (GI->hasInitializer() && !GI->isConstant()) { // read-write data
+ enterSection(AsmPrinter::ReadOnlyData); // read-only, initialized data
+ } else if (GI->hasInitializer() && !GI->isConstant()) { // read-write data
+ enterSection(AsmPrinter::InitRWData);
+ } else {
+ assert (!GI->hasInitializer() && "Unexpected global variable type found");
+ enterSection(AsmPrinter::UninitRWData); // Uninitialized data
+ }
+ printGlobalVariable(GI);
+ }
+
toAsm << "\n";
}