Don't output explicit initializers for globals that are zero initialized
authorChris Lattner <sabre@nondot.org>
Fri, 6 Jun 2003 07:10:24 +0000 (07:10 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 Jun 2003 07:10:24 +0000 (07:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6651 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 954266163b1a76ede05a4748d3dd38d1bf8ec812..39e09fb40f3d643a82424dd61ea67a733701b22f 100644 (file)
@@ -73,7 +73,6 @@ namespace {
     void printModule(Module *M);
     void printSymbolTable(const SymbolTable &ST);
     void printContainedStructs(const Type *Ty, std::set<const StructType *> &);
-    void printGlobal(const GlobalVariable *GV);
     void printFunctionSignature(const Function *F, bool Prototype);
 
     void printFunction(Function *);
@@ -619,9 +618,10 @@ void CWriter::printModule(Module *M) {
         if (I->hasInternalLinkage())
           Out << "static ";
         printType(Out, I->getType()->getElementType(), getValueName(I));
-      
-        Out << " = " ;
-        writeOperand(I->getInitializer());
+        if (!I->getInitializer()->isNullValue()) {
+          Out << " = " ;
+          writeOperand(I->getInitializer());
+        }
         Out << ";\n";
       }
   }
index 954266163b1a76ede05a4748d3dd38d1bf8ec812..39e09fb40f3d643a82424dd61ea67a733701b22f 100644 (file)
@@ -73,7 +73,6 @@ namespace {
     void printModule(Module *M);
     void printSymbolTable(const SymbolTable &ST);
     void printContainedStructs(const Type *Ty, std::set<const StructType *> &);
-    void printGlobal(const GlobalVariable *GV);
     void printFunctionSignature(const Function *F, bool Prototype);
 
     void printFunction(Function *);
@@ -619,9 +618,10 @@ void CWriter::printModule(Module *M) {
         if (I->hasInternalLinkage())
           Out << "static ";
         printType(Out, I->getType()->getElementType(), getValueName(I));
-      
-        Out << " = " ;
-        writeOperand(I->getInitializer());
+        if (!I->getInitializer()->isNullValue()) {
+          Out << " = " ;
+          writeOperand(I->getInitializer());
+        }
         Out << ";\n";
       }
   }