Bug fix: In preventing static global variables from being printed twice,
authorVikram S. Adve <vadve@cs.uiuc.edu>
Sat, 5 Oct 2002 23:43:10 +0000 (23:43 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Sat, 5 Oct 2002 23:43:10 +0000 (23:43 +0000)
I also prevented external globals from being printed twice, but they
should (extern declaration and definition).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4043 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index bc2106d78fec9333b90776d91442bbf160cc4774..51a3d168c17e0e5043129ef4e907a1a3153cb374 100644 (file)
@@ -563,9 +563,8 @@ void CWriter::printModule(Module *M) {
   if (!M->gempty()) {
     Out << "\n\n/* Global Variable Definitions and Initialization */\n";
     for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
-      if (I->hasExternalLinkage())
-        continue;                       // printed above!
-      Out << "static ";
+      if (I->hasInternalLinkage())
+        Out << "static ";
       printType(I->getType()->getElementType(), getValueName(I));
       
       if (I->hasInitializer()) {
index bc2106d78fec9333b90776d91442bbf160cc4774..51a3d168c17e0e5043129ef4e907a1a3153cb374 100644 (file)
@@ -563,9 +563,8 @@ void CWriter::printModule(Module *M) {
   if (!M->gempty()) {
     Out << "\n\n/* Global Variable Definitions and Initialization */\n";
     for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
-      if (I->hasExternalLinkage())
-        continue;                       // printed above!
-      Out << "static ";
+      if (I->hasInternalLinkage())
+        Out << "static ";
       printType(I->getType()->getElementType(), getValueName(I));
       
       if (I->hasInitializer()) {