summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-09-17 11:50:38 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-09-17 11:50:38 +0000
commit913bfbc2e48c67c1729a88bb00538811211ac66d (patch)
tree8a7f8b3d5a9e1576bf4b404f0aed044b554630a6 /lib
parent0e9843db54f87be7dfe383a375585dcdeff353f3 (diff)
downloadllvm-913bfbc2e48c67c1729a88bb00538811211ac66d.tar.gz
llvm-913bfbc2e48c67c1729a88bb00538811211ac66d.tar.bz2
llvm-913bfbc2e48c67c1729a88bb00538811211ac66d.tar.xz
Don't print global variable definitions twice! Sun's pathetic compiler
never complained about this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3774 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/CBackend/CBackend.cpp18
-rw-r--r--lib/Target/CBackend/Writer.cpp18
2 files changed, 22 insertions, 14 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 4d53b7adf6..319b362bdf 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -522,11 +522,13 @@ void CWriter::printModule(Module *M) {
// Global variable declarations...
if (!M->gempty()) {
- Out << "\n/* Global Variable Declarations */\n";
+ Out << "\n/* External Global Variable Declarations */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- Out << (I->hasExternalLinkage() ? "extern " : "static ");
- printType(I->getType()->getElementType(), getValueName(I));
- Out << ";\n";
+ if (I->hasExternalLinkage()) {
+ Out << "extern ";
+ printType(I->getType()->getElementType(), getValueName(I));
+ Out << ";\n";
+ }
}
}
@@ -539,11 +541,13 @@ void CWriter::printModule(Module *M) {
}
}
- // Output the global variable contents...
+ // Output the global variable definitions and contents...
if (!M->gempty()) {
- Out << "\n\n/* Global Data */\n";
+ Out << "\n\n/* Global Variable Definitions and Initialization */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- if (I->hasInternalLinkage()) Out << "static ";
+ if (I->hasExternalLinkage())
+ continue; // printed above!
+ Out << "static ";
printType(I->getType()->getElementType(), getValueName(I));
if (I->hasInitializer()) {
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 4d53b7adf6..319b362bdf 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -522,11 +522,13 @@ void CWriter::printModule(Module *M) {
// Global variable declarations...
if (!M->gempty()) {
- Out << "\n/* Global Variable Declarations */\n";
+ Out << "\n/* External Global Variable Declarations */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- Out << (I->hasExternalLinkage() ? "extern " : "static ");
- printType(I->getType()->getElementType(), getValueName(I));
- Out << ";\n";
+ if (I->hasExternalLinkage()) {
+ Out << "extern ";
+ printType(I->getType()->getElementType(), getValueName(I));
+ Out << ";\n";
+ }
}
}
@@ -539,11 +541,13 @@ void CWriter::printModule(Module *M) {
}
}
- // Output the global variable contents...
+ // Output the global variable definitions and contents...
if (!M->gempty()) {
- Out << "\n\n/* Global Data */\n";
+ Out << "\n\n/* Global Variable Definitions and Initialization */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- if (I->hasInternalLinkage()) Out << "static ";
+ if (I->hasExternalLinkage())
+ continue; // printed above!
+ Out << "static ";
printType(I->getType()->getElementType(), getValueName(I));
if (I->hasInitializer()) {