[PATCH] D14697: [Verifier] Fix !dbg validation if Scope is the Subprogram

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 08:30:40 PST 2015


This seems like a slightly weird algorithm

We check if the debug location itself is seen, then if the immediate scope
is seen, then we walk the entire scope chain until we get to the top level
subprogram and check if that's already seen. Why not check the intermediate
scopes too, if checking the first and last are both worthwhile...

& if we actually check everything along the chain, then maybe this should
fall out more naturally?

On Mon, Nov 16, 2015 at 2:48 AM, Keno Fischer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> loladiro updated this revision to Diff 40264.
> loladiro added a comment.
>
> Small formatting fix
>
>
> http://reviews.llvm.org/D14697
>
> Files:
>   lib/IR/Verifier.cpp
>   test/CodeGen/X86/2010-05-28-Crash.ll
>   test/Verifier/func-dbg.ll
>
> Index: test/Verifier/func-dbg.ll
> ===================================================================
> --- /dev/null
> +++ test/Verifier/func-dbg.ll
> @@ -0,0 +1,25 @@
> +; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
> +
> +define i32 @foo() !dbg !4 {
> +entry:
> +  ret i32 0, !dbg !6
> +}
> +
> +define i32 @bar() !dbg !5 {
> +entry:
> +; CHECK: !dbg attachment points at wrong subprogram for function
> +  ret i32 0, !dbg !6
> +}
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!7, !8}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer:
> "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 0, enums: !2,
> retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
> +!1 = !DIFile(filename: "dwarf-test.c", directory: "test")
> +!2 = !{}
> +!3 = !{!4, !5}
> +!4 = distinct !DISubprogram(name: "foo", scope: !0, isDefinition: true)
> +!5 = distinct !DISubprogram(name: "bar", scope: !0, isDefinition: true)
> +!6 = !DILocation(line: 7, scope: !4)
> +!7 = !{i32 2, !"Dwarf Version", i32 3}
> +!8 = !{i32 1, !"Debug Info Version", i32 3}
> Index: test/CodeGen/X86/2010-05-28-Crash.ll
> ===================================================================
> --- test/CodeGen/X86/2010-05-28-Crash.ll
> +++ test/CodeGen/X86/2010-05-28-Crash.ll
> @@ -16,7 +16,7 @@
>  define i32 @bar(i32 %x) nounwind optsize ssp !dbg !8 {
>  entry:
>    tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !7,
> metadata !DIExpression()), !dbg !DILocation(scope: !8)
> -  tail call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !0,
> metadata !DIExpression()) nounwind, !dbg !DILocation(scope: !1)
> +  tail call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !0,
> metadata !DIExpression()) nounwind, !dbg !DILocation(scope: !1, inlinedAt:
> !DILocation(scope: !8))
>    %0 = tail call i32 (...) @zoo(i32 1) nounwind, !dbg !12 ; <i32>
> [#uses=1]
>    %1 = add nsw i32 %0, %x, !dbg !13               ; <i32> [#uses=1]
>    ret i32 %1, !dbg !13
> Index: lib/IR/Verifier.cpp
> ===================================================================
> --- lib/IR/Verifier.cpp
> +++ lib/IR/Verifier.cpp
> @@ -1806,7 +1806,10 @@
>          continue;
>
>        DISubprogram *SP = Scope ? Scope->getSubprogram() : nullptr;
> -      if (SP && !Seen.insert(SP).second)
> +
> +      // Scope and SP could be the same MDNode and we don't want to skip
> +      // validation in that case
> +      if (SP && ((Scope != SP) && !Seen.insert(SP).second))
>          continue;
>
>        // FIXME: Once N is canonical, check "SP == &N".
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/ef8e3923/attachment.html>


More information about the llvm-commits mailing list