diff options
author | Adrian Prantl <aprantl@apple.com> | 2018-08-24 21:01:58 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2018-08-24 21:01:58 +0000 |
commit | 3807217d028dd00ba3d7c3476f226c9d12d52007 (patch) | |
tree | df4f9ba41cf6d7408a307adfbbff9871234f3244 | |
parent | 6328ccc14c3a232d8af763b946f2d6878013b790 (diff) | |
download | bcm5719-llvm-3807217d028dd00ba3d7c3476f226c9d12d52007.tar.gz bcm5719-llvm-3807217d028dd00ba3d7c3476f226c9d12d52007.zip |
Verifier: verify that a DILocation's scope is a DILocalScope.
This fixes an assertion failure(!) in the Verifier.
rdar://problem/43687474
llvm-svn: 340653
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Verifier/DILocation-scope.ll | 24 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5bc731c3266..2dcb9c4adf8 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2264,6 +2264,10 @@ void Verifier::visitFunction(const Function &F) { if (!Seen.insert(DL).second) continue; + Metadata *Parent = DL->getRawScope(); + AssertDI(Parent && isa<DILocalScope>(Parent), + "DILocation's scope must be a DILocalScope", N, &F, &I, DL, + Parent); DILocalScope *Scope = DL->getInlinedAtScope(); if (Scope && !Seen.insert(Scope).second) continue; diff --git a/llvm/test/Verifier/DILocation-scope.ll b/llvm/test/Verifier/DILocation-scope.ll new file mode 100644 index 00000000000..5cac5aead82 --- /dev/null +++ b/llvm/test/Verifier/DILocation-scope.ll @@ -0,0 +1,24 @@ +; RUN: llvm-as -disable-output %s -o - 2>&1 | FileCheck %s +source_filename = "t.c" +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.13.0" + +define void @f() !dbg !4 { +entry: +; CHECK: scope must be a DILocalScope +; CHECK: DILocation + ret void, !dbg !6 +} + +; CHECK: warning: ignoring invalid debug info + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug) +!1 = !DIFile(filename: "t.c", directory: "/tmp") +!2 = !{i32 2, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !5, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, unit: !0) +!5 = !DISubroutineType(types: !{}) +!6 = !DILocation(line: 2, scope: !1) |