fix formatting; NFC
[oota-llvm.git] / test / DebugInfo / X86 / lexical-block-pr19238.ll
1 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s  | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2
3 ;; This test checks the following:
4 ;; 1. Useless lexical block entry is not emitted
5 ;; 2. Function static variable, typedef, records (structure, class and union)
6 ;;    that are defined in lexical basic block are emitted as children to
7 ;;    these lexical blocks.
8 ;;    * For typedef and record check that both are emitted in lexical block
9 ;;      where they are declared and not in the one where they are used.
10 ;;
11 ;; This test was generated by running following command:
12 ;; clang -cc1 -O0 -g -emit-llvm foo.cpp 
13 ;; Where foo.cpp
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 ;;int foo(void) { 
16 ;;  {
17 ;;    {
18 ;;      struct X {
19 ;;        int x;
20 ;;      };
21 ;;      typedef int Y;
22 ;;      {
23 ;;        X a;
24 ;;        Y b;
25 ;;        static int c;
26 ;;        return a.x + b + c;
27 ;;      }
28 ;;    }
29 ;;  }
30 ;;}
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
32
33
34 ; CHECK:      DW_TAG_subprogram
35 ; CHECK-NOT: DW_TAG
36 ; CHECK:        DW_AT_name {{.*}} "foo"
37 ; CHECK-NOT: NULL
38 ; CHECK:      DW_TAG_lexical_block
39
40 ; CHECK-NOT: {{DW_TAG|NULL}}
41 ; CHECK:        DW_TAG_structure_type
42 ; CHECK-NOT: {{DW_TAG|NULL}}
43 ; CHECK:          DW_AT_name {{.*}} "X"
44 ; CHECK:          NULL
45
46 ; CHECK-NOT: {{DW_TAG|NULL}}
47 ; CHECK:        DW_TAG_typedef
48 ; CHECK-NOT: {{DW_TAG|NULL}}
49 ; CHECK:          DW_AT_name {{.*}} "Y"
50
51 ; CHECK-NOT: {{DW_TAG|NULL}}
52 ; CHECK:        DW_TAG_lexical_block
53
54 ; CHECK-NOT: {{DW_TAG|NULL}}
55 ; CHECK:        DW_TAG_variable
56 ; CHECK-NOT: {{DW_TAG|NULL}}
57 ; CHECK:          DW_AT_name {{.*}} "c"
58
59 ; CHECK-NOT: {{DW_TAG|NULL}}
60 ; CHECK:        DW_TAG_variable
61 ; CHECK-NOT: {{DW_TAG|NULL}}
62 ; CHECK:          DW_AT_name {{.*}} "a"
63
64 ; CHECK-NOT: {{DW_TAG|NULL}}
65 ; CHECK:        DW_TAG_variable
66 ; CHECK-NOT: {{DW_TAG|NULL}}
67 ; CHECK:          DW_AT_name {{.*}} "b"
68
69 ; CHECK-NOT: {{DW_TAG}}
70 ; CHECK:        NULL
71
72
73 %struct.X = type { i32 }
74
75 @_ZZ3foovE1c = internal global i32 0, align 4
76
77 ; Function Attrs: nounwind
78 define i32 @_Z3foov() #0 {
79 entry:
80   %a = alloca %struct.X, align 4
81   %b = alloca i32, align 4
82   call void @llvm.dbg.declare(metadata %struct.X* %a, metadata !21, metadata !22), !dbg !23
83   call void @llvm.dbg.declare(metadata i32* %b, metadata !24, metadata !22), !dbg !25
84   %x = getelementptr inbounds %struct.X, %struct.X* %a, i32 0, i32 0, !dbg !26
85   %0 = load i32, i32* %x, align 4, !dbg !26
86   %1 = load i32, i32* %b, align 4, !dbg !26
87   %add = add nsw i32 %0, %1, !dbg !26
88   %2 = load i32, i32* @_ZZ3foovE1c, align 4, !dbg !26
89   %add1 = add nsw i32 %add, %2, !dbg !26
90   ret i32 %add1, !dbg !26
91 }
92
93 ; Function Attrs: nounwind readnone
94 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
95
96 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
97 attributes #1 = { nounwind readnone }
98
99 !llvm.dbg.cu = !{!0}
100 !llvm.module.flags = !{!18, !19}
101 !llvm.ident = !{!20}
102
103 !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7.0 (trunk 237245)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !15, imports: !2)
104 !1 = !DIFile(filename: "foo.cpp", directory: "/")
105 !2 = !{}
106 !3 = !{!4, !13}
107 !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11)
108 !5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3)
109 !6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2)
110 !7 = !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, function: i32 ()* @_Z3foov, variables: !2)
111 !8 = !DISubroutineType(types: !9)
112 !9 = !{!10}
113 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
114 !11 = !{!12}
115 !12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 5, baseType: !10, size: 32, align: 32)
116 !13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10)
117 !14 = !{!7}
118 !15 = !{!16}
119 !16 = !DIGlobalVariable(name: "c", scope: !17, file: !1, line: 11, type: !10, isLocal: true, isDefinition: true, variable: i32* @_ZZ3foovE1c)
120 !17 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8)
121 !18 = !{i32 2, !"Dwarf Version", i32 4}
122 !19 = !{i32 2, !"Debug Info Version", i32 3}
123 !20 = !{!"clang version 3.7.0 (trunk 237245)"}
124 !21 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "a", scope: !17, file: !1, line: 9, type: !4)
125 !22 = !DIExpression()
126 !23 = !DILocation(line: 9, scope: !17)
127 !24 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "b", scope: !17, file: !1, line: 10, type: !13)
128 !25 = !DILocation(line: 10, scope: !17)
129 !26 = !DILocation(line: 12, scope: !17)