diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 585a087a02a..e30c0a9b330 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -68,7 +68,7 @@ uint64_t DIDescriptor::getUInt64Field(unsigned Elt) const { return 0; if (Elt < DbgNode->getNumOperands()) - if (ConstantInt *CI = dyn_cast(DbgNode->getOperand(Elt))) + if (ConstantInt *CI = dyn_cast_or_null(DbgNode->getOperand(Elt))) return CI->getZExtValue(); return 0; diff --git a/test/DebugInfo/bug_null_debuginfo.ll b/test/DebugInfo/bug_null_debuginfo.ll new file mode 100644 index 00000000000..a7fdf70d71c --- /dev/null +++ b/test/DebugInfo/bug_null_debuginfo.ll @@ -0,0 +1,6 @@ +; RUN: llc + + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{null, null, null}