Don't emit a null terminator, nor anything after it, to the ctor/dtor list
authorChris Lattner <sabre@nondot.org>
Wed, 21 Dec 2005 01:17:37 +0000 (01:17 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 21 Dec 2005 01:17:37 +0000 (01:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24887 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter.cpp

index 0539d4632502bcbabe9c135eb375a06f67ee07f6..26a3d39db5e44a58a7f86403bd0bbadfdd40ac9b 100644 (file)
@@ -146,7 +146,10 @@ void AsmPrinter::EmitXXStructorList(Constant *List) {
   for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
     if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){
       if (CS->getNumOperands() != 2) return;  // Not array of 2-element structs.
-                                              // Emit the function pointer.
+
+      if (CS->getOperand(1)->isNullValue())
+        return;  // Found a null terminator, exit printing.
+      // Emit the function pointer.
       EmitGlobalConstant(CS->getOperand(1));
     }
 }