diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 31f1e19a945..deeaae7d5de 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -1537,7 +1537,7 @@ bool llvm::StripDebugInfo(Module &M) { } unsigned llvm::getDebugMetadataVersionFromModule(const Module &M) { - if (auto *Val = mdconst::extract_or_null( + if (auto *Val = mdconst::dyn_extract_or_null( M.getModuleFlag("Debug Info Version"))) return Val->getZExtValue(); return 0; diff --git a/test/Assembler/invalid-debug-info-version.ll b/test/Assembler/invalid-debug-info-version.ll new file mode 100644 index 00000000000..94a81538562 --- /dev/null +++ b/test/Assembler/invalid-debug-info-version.ll @@ -0,0 +1,5 @@ +; RUN: opt < %s -S | FileCheck %s + +!llvm.module.flags = !{!0} +!0 = !{i32 1, !"Debug Info Version", !""} +; CHECK: !{i32 1, !"Debug Info Version", !""}