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