Avoid printing out huge structures or arrays if they are just filled with zeros
authorChris Lattner <sabre@nondot.org>
Sat, 28 Jun 2003 20:08:24 +0000 (20:08 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Jun 2003 20:08:24 +0000 (20:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6938 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp

index afc4b6d63c6fc856ef61b7327b9dbd3b177fc5a1..a6d6cbe83c327b3feea1bfd6a12901934fed8115 100644 (file)
@@ -253,6 +253,11 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
     Out << "0x" << utohexstr(*(uint64_t*)Ptr);
 
   } else if (const ConstantArray *CA = dyn_cast<ConstantArray>(CV)) {
+    if (CA->getNumOperands() > 5 && CA->isNullValue()) {
+      Out << "zeroinitializer";
+      return;
+    }
+
     // As a special case, print the array as a string if it is an array of
     // ubytes or an array of sbytes with positive values.
     // 
@@ -300,6 +305,11 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV,
       Out << " ]";
     }
   } else if (const ConstantStruct *CS = dyn_cast<ConstantStruct>(CV)) {
+    if (CS->getNumOperands() > 5 && CS->isNullValue()) {
+      Out << "zeroinitializer";
+      return;
+    }
+
     Out << "{";
     if (CS->getNumOperands()) {
       Out << " ";