Fix bug: CBackend/2002-10-16-External.ll
authorChris Lattner <sabre@nondot.org>
Wed, 16 Oct 2002 20:08:47 +0000 (20:08 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 16 Oct 2002 20:08:47 +0000 (20:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4201 91177308-0d34-0410-b5e6-96231b3b80d8

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

index feaf1352695d0b50f965e58d3d93f4956768be07..b7207d5414e5c347908d397e7ed018bda0528d82 100644 (file)
@@ -572,17 +572,16 @@ void CWriter::printModule(Module *M) {
   // Output the global variable definitions and contents...
   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->hasInternalLinkage())
-        Out << "static ";
-      printType(I->getType()->getElementType(), getValueName(I));
+    for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
+      if (!I->isExternal()) {
+        if (I->hasInternalLinkage())
+          Out << "static ";
+        printType(I->getType()->getElementType(), getValueName(I));
       
-      if (I->hasInitializer()) {
         Out << " = " ;
         writeOperand(I->getInitializer());
+        Out << ";\n";
       }
-      Out << ";\n";
-    }
   }
 
   // Output all of the functions...
index feaf1352695d0b50f965e58d3d93f4956768be07..b7207d5414e5c347908d397e7ed018bda0528d82 100644 (file)
@@ -572,17 +572,16 @@ void CWriter::printModule(Module *M) {
   // Output the global variable definitions and contents...
   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->hasInternalLinkage())
-        Out << "static ";
-      printType(I->getType()->getElementType(), getValueName(I));
+    for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I)
+      if (!I->isExternal()) {
+        if (I->hasInternalLinkage())
+          Out << "static ";
+        printType(I->getType()->getElementType(), getValueName(I));
       
-      if (I->hasInitializer()) {
         Out << " = " ;
         writeOperand(I->getInitializer());
+        Out << ";\n";
       }
-      Out << ";\n";
-    }
   }
 
   // Output all of the functions...