[llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 19 23:50:00 PST 2004


Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.162 -> 1.163

---
Log message:

It is totally unacceptable to print out (literally) millions of zeros when
compiling 129.compress... so don't!


---
Diffs of the changes:  (+13 -2)

Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.162 llvm/lib/Target/CBackend/Writer.cpp:1.163
--- llvm/lib/Target/CBackend/Writer.cpp:1.162	Sun Feb 15 16:51:47 2004
+++ llvm/lib/Target/CBackend/Writer.cpp	Thu Feb 19 23:49:22 2004
@@ -728,10 +728,21 @@
         // 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";
       }





More information about the llvm-commits mailing list