don't send null pointers through the constantexpr codepath unneededly.
authorChris Lattner <sabre@nondot.org>
Wed, 20 Jan 2010 17:57:50 +0000 (17:57 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 20 Jan 2010 17:57:50 +0000 (17:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94010 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp

index 4c5e079f03be2a928ddb75e602efe98a48af9e09..32e9036af94f74a83385957141e4c76677a563fa 100644 (file)
@@ -1247,6 +1247,12 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
   if (const ConstantVector *V = dyn_cast<ConstantVector>(CV))
     return EmitGlobalConstantVector(V, AddrSpace, *this);
 
+  if (isa<ConstantPointerNull>(CV)) {
+    unsigned Size = TM.getTargetData()->getTypeAllocSize(CV->getType());
+    OutStreamer.EmitIntValue(0, Size, AddrSpace);
+    return;
+  }
+  
   // Otherwise, it must be a ConstantExpr.  Emit the data directive, then emit
   // the expression value.
   switch (TM.getTargetData()->getTypeAllocSize(CV->getType())) {