xref: /llvm-project/llvm/test/CodeGen/X86/debug-nodebug-crash.ll (revision 2c864551df3945f50e1780b2f2c880ec358ae715)
13610942cSWolfgang Pieb;RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
2e018bbd8SWolfgang Pieb;
3e018bbd8SWolfgang Pieb; LexicalScope objects were not cleared when a nodebug function is handled in
4e018bbd8SWolfgang Pieb; LiveDebugValues. This may lead to an assertion in the constructor for LexicalScope,
5e018bbd8SWolfgang Pieb; triggered by LiveDebugValues when another (debug) function is handled later.
6e018bbd8SWolfgang Pieb;
7e018bbd8SWolfgang Pieb; This minimal example does not leave much to check for, so we just make sure we get
8e018bbd8SWolfgang Pieb; reasonable output, preserving function labels and a DBG_VALUE comment.
9e018bbd8SWolfgang Pieb;
10e018bbd8SWolfgang Pieb; CHECK-LABEL: foo:
11e018bbd8SWolfgang Pieb; CHECK-NEXT:  Lfunc_begin0:
12e018bbd8SWolfgang Pieb; CHECK:       Lfunc_end0:
13e018bbd8SWolfgang Pieb; CHECK-LABEL: bar:
14e018bbd8SWolfgang Pieb; CHECK-NEXT:  Lfunc_begin1:
15e018bbd8SWolfgang Pieb; CHECK:       #DEBUG_VALUE: foo:x <-
16e018bbd8SWolfgang Pieb; CHECK:       Lfunc_end1:
17e018bbd8SWolfgang Pieb
18e018bbd8SWolfgang Piebdefine i32 @foo() {
19e018bbd8SWolfgang Piebentry:
20e018bbd8SWolfgang Pieb  ret i32 0
21e018bbd8SWolfgang Pieb}
22e018bbd8SWolfgang Pieb
23e018bbd8SWolfgang Piebdefine i32 @bar(i32 %x) !dbg !50 {
24e018bbd8SWolfgang Piebentry:
25e018bbd8SWolfgang Pieb  tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !41, metadata !43), !dbg !52
26e018bbd8SWolfgang Pieb  %tobool.i = icmp eq i32 %x, 0
27e018bbd8SWolfgang Pieb  br i1 %tobool.i, label %foo.exit, label %if.then.i
28e018bbd8SWolfgang Pieb
29e018bbd8SWolfgang Piebif.then.i:
30e018bbd8SWolfgang Pieb  br label %foo.exit
31e018bbd8SWolfgang Pieb
32e018bbd8SWolfgang Piebfoo.exit:
33e018bbd8SWolfgang Pieb  %x.addr.0.i = phi i32 [ 1, %if.then.i ], [ 0, %entry ]
34e018bbd8SWolfgang Pieb  ret i32 %x.addr.0.i
35e018bbd8SWolfgang Pieb}
36e018bbd8SWolfgang Pieb
37e018bbd8SWolfgang Piebdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata)
38e018bbd8SWolfgang Pieb
39e018bbd8SWolfgang Pieb!llvm.dbg.cu = !{!0, !3}
40e018bbd8SWolfgang Pieb!llvm.ident = !{!5, !5}
41e018bbd8SWolfgang Pieb!llvm.module.flags = !{!6, !7}
42e018bbd8SWolfgang Pieb
43e018bbd8SWolfgang Pieb!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
44e018bbd8SWolfgang Pieb!1 = !DIFile(filename: "foo.cpp", directory: "c:\temp")
45e018bbd8SWolfgang Pieb!2 = !{}
46e018bbd8SWolfgang Pieb!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
47e018bbd8SWolfgang Pieb!4 = !DIFile(filename: "bar.cpp", directory: "c:\temp")
48e018bbd8SWolfgang Pieb!5 = !{!"clang version 4.0.0"}
49e018bbd8SWolfgang Pieb!6 = !{i32 2, !"Dwarf Version", i32 4}
50e018bbd8SWolfgang Pieb!7 = !{i32 2, !"Debug Info Version", i32 3}
51*2c864551SShiva Chen!36 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !37, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !40)
52e018bbd8SWolfgang Pieb!37 = !DISubroutineType(types: !38)
53e018bbd8SWolfgang Pieb!38 = !{!39, !39}
54e018bbd8SWolfgang Pieb!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
55e018bbd8SWolfgang Pieb!40 = !{!41}
56e018bbd8SWolfgang Pieb!41 = !DILocalVariable(name: "x", arg: 1, scope: !36, file: !1, line: 1, type: !39)
57e018bbd8SWolfgang Pieb!43 = !DIExpression()
58*2c864551SShiva Chen!50 = distinct !DISubprogram(name: "bar", scope: !4, file: !4, line: 3, type: !51, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !3, retainedNodes: !2)
59e018bbd8SWolfgang Pieb!51 = !DISubroutineType(types: !2)
60e018bbd8SWolfgang Pieb!52 = !DILocation(line: 1, scope: !36, inlinedAt: !53)
61e018bbd8SWolfgang Pieb!53 = distinct !DILocation(line: 5, scope: !50)
62