From a4a0cf8394627f8380c9e14b20900001efd56dee Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 16 Mar 2012 00:21:54 +0000 Subject: [PATCH] Do the right thing on NULL uint64 fields. Patch by Clemens Hammacher! Fixes PR12243 llvm-svn: 152880 --- llvm/lib/Analysis/DebugInfo.cpp | 2 +- llvm/test/DebugInfo/bug_null_debuginfo.ll | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 llvm/test/DebugInfo/bug_null_debuginfo.ll diff --git a/llvm/lib/Analysis/DebugInfo.cpp b/llvm/lib/Analysis/DebugInfo.cpp index 585a087a02ac..e30c0a9b3306 100644 --- a/llvm/lib/Analysis/DebugInfo.cpp +++ b/llvm/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/llvm/test/DebugInfo/bug_null_debuginfo.ll b/llvm/test/DebugInfo/bug_null_debuginfo.ll new file mode 100644 index 000000000000..a7fdf70d71c7 --- /dev/null +++ b/llvm/test/DebugInfo/bug_null_debuginfo.ll @@ -0,0 +1,6 @@ +; RUN: llc + + +!llvm.dbg.cu = !{!0} + +!0 = metadata !{null, null, null}