It is totally unacceptable to print out (literally) millions of zeros when
authorChris Lattner <sabre@nondot.org>
Fri, 20 Feb 2004 05:49:22 +0000 (05:49 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 20 Feb 2004 05:49:22 +0000 (05:49 +0000)
compiling 129.compress... so don't!

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

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

index b52db0346a9a60f0752ffc06ce98524e2853a6b2..93e5b07f5f2ab57c4f6d0334e326c35a62a7c743 100644 (file)
@@ -728,10 +728,21 @@ bool CWriter::doInitialization(Module &M) {
         // this, however, occurs when the variable has weak linkage.  In this
         // case, the assembler will complain about the variable being both weak
         // and common, so we disable this optimization.
-        if (!I->getInitializer()->isNullValue() ||
-            I->hasWeakLinkage()) {
+        if (!I->getInitializer()->isNullValue()) {
           Out << " = " ;
           writeOperand(I->getInitializer());
+        } else if (I->hasWeakLinkage()) {
+          // We have to specify an initializer, but it doesn't have to be
+          // complete.  If the value is an aggregate, print out { 0 }, and let
+          // the compiler figure out the rest of the zeros.
+          Out << " = " ;
+          if (isa<StructType>(I->getInitializer()->getType()) ||
+              isa<ArrayType>(I->getInitializer()->getType())) {
+            Out << "{ 0 }";
+          } else {
+            // Just print it out normally.
+            writeOperand(I->getInitializer());
+          }
         }
         Out << ";\n";
       }
index b52db0346a9a60f0752ffc06ce98524e2853a6b2..93e5b07f5f2ab57c4f6d0334e326c35a62a7c743 100644 (file)
@@ -728,10 +728,21 @@ bool CWriter::doInitialization(Module &M) {
         // this, however, occurs when the variable has weak linkage.  In this
         // case, the assembler will complain about the variable being both weak
         // and common, so we disable this optimization.
-        if (!I->getInitializer()->isNullValue() ||
-            I->hasWeakLinkage()) {
+        if (!I->getInitializer()->isNullValue()) {
           Out << " = " ;
           writeOperand(I->getInitializer());
+        } else if (I->hasWeakLinkage()) {
+          // We have to specify an initializer, but it doesn't have to be
+          // complete.  If the value is an aggregate, print out { 0 }, and let
+          // the compiler figure out the rest of the zeros.
+          Out << " = " ;
+          if (isa<StructType>(I->getInitializer()->getType()) ||
+              isa<ArrayType>(I->getInitializer()->getType())) {
+            Out << "{ 0 }";
+          } else {
+            // Just print it out normally.
+            writeOperand(I->getInitializer());
+          }
         }
         Out << ";\n";
       }