[llvm] r340653 - Verifier: verify that a DILocation's scope is a DILocalScope.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 24 14:01:59 PDT 2018


Author: adrian
Date: Fri Aug 24 14:01:58 2018
New Revision: 340653

URL: http://llvm.org/viewvc/llvm-project?rev=340653&view=rev
Log:
Verifier: verify that a DILocation's scope is a DILocalScope.

This fixes an assertion failure(!) in the Verifier.

rdar://problem/43687474

Added:
    llvm/trunk/test/Verifier/DILocation-scope.ll
Modified:
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=340653&r1=340652&r2=340653&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Aug 24 14:01:58 2018
@@ -2264,6 +2264,10 @@ void Verifier::visitFunction(const Funct
       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;

Added: llvm/trunk/test/Verifier/DILocation-scope.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/DILocation-scope.ll?rev=340653&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/DILocation-scope.ll (added)
+++ llvm/trunk/test/Verifier/DILocation-scope.ll Fri Aug 24 14:01:58 2018
@@ -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)




More information about the llvm-commits mailing list