Prevent a crash in debug dumps.
[oota-llvm.git] / lib / VMCore / AsmWriter.cpp
index d8372ef0063637af48f21c3895f095c5a3f6ea43..9e010051a51102c08c06818e5e4140d11ffbcfd8 100644 (file)
@@ -979,7 +979,11 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
 }
 
 void AssemblyWriter::printAlias(const GlobalAlias *GA) {
-  Out << getLLVMName(GA->getName(), GlobalPrefix) << " = ";
+  // Don't crash when dumping partially built GA
+  if (!GA->hasName())
+    Out << "<<nameless>> = ";
+  else
+    Out << getLLVMName(GA->getName(), GlobalPrefix) << " = ";
   switch (GA->getVisibility()) {
   default: assert(0 && "Invalid visibility style!");
   case GlobalValue::DefaultVisibility: break;