Minimally fix this code to not abort on mdnodes with integer data
authorDan Gohman <gohman@apple.com>
Fri, 7 May 2010 22:15:24 +0000 (22:15 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 7 May 2010 22:15:24 +0000 (22:15 +0000)
wider than 64 bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103309 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp

index 6c1aa5ed10c6f8d971344019522060606fb0bb16..fc845c14e88d15e4ca6c74cee45fc3cc6c924069 100644 (file)
@@ -2024,9 +2024,9 @@ static void WriteMDNodeComment(const MDNode *Node,
     return;
   ConstantInt *CI = dyn_cast_or_null<ConstantInt>(Node->getOperand(0));
   if (!CI) return;
-  unsigned Val = CI->getZExtValue();
-  unsigned Tag = Val & ~LLVMDebugVersionMask;
-  if (Val < LLVMDebugVersion)
+  APInt Val = CI->getValue();
+  APInt Tag = Val & ~APInt(Val.getBitWidth(), LLVMDebugVersionMask);
+  if (Val.ult(LLVMDebugVersion))
     return;
   
   Out.PadToColumn(50);
@@ -2040,8 +2040,10 @@ static void WriteMDNodeComment(const MDNode *Node,
     Out << "; [ DW_TAG_vector_type ]";
   else if (Tag == dwarf::DW_TAG_user_base)
     Out << "; [ DW_TAG_user_base ]";
-  else if (const char *TagName = dwarf::TagString(Tag))
-    Out << "; [ " << TagName << " ]";
+  else if (Tag.isIntN(32)) {
+    if (const char *TagName = dwarf::TagString(Tag.getZExtValue()))
+      Out << "; [ " << TagName << " ]";
+  }
 }
 
 void AssemblyWriter::writeAllMDNodes() {