1; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=ASM
2; RUN: llc -mtriple=x86_64-windows-msvc < %s -filetype=obj | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
3
4; This LL file was generated by running 'clang -g -gcodeview' on the
5; following code:
6;  1: extern "C" volatile int x;
7;  2: extern "C" void capture(int *p);
8;  3: static __forceinline inline void will_be_inlined() {
9;  4:   int v = 3;
10;  5:   capture(&v);
11;  6: }
12;  7: extern "C" void f(int param) {
13;  8:   if (param) {
14;  9:     int a = 42;
15; 10:     will_be_inlined();
16; 11:     capture(&a);
17; 12:   } else {
18; 13:     int b = 42;
19; 14:     will_be_inlined();
20; 15:     capture(&b);
21; 16:   }
22; 17: }
23
24; ASM: f:                                      # @f
25; ASM:         .cv_func_id 0
26; ASM:         .cv_file        1 "D:\\src\\llvm\\build\\t.cpp"
27; ASM:         .cv_loc 0 1 7 0       # t.cpp:7:0
28; ASM: .seh_proc f
29; ASM: # %bb.0:                                 # %entry
30; ASM:         subq    $56, %rsp
31; ASM:         movl    %ecx, 52(%rsp)
32; ASM: [[prologue_end:\.Ltmp.*]]:
33; ASM:         .cv_loc 0 1 8 7                 # t.cpp:8:7
34; ASM:         testl   %ecx, %ecx
35; ASM:         je      .LBB0_2
36; ASM: # %bb.1:                                 # %if.then
37; ASM: [[if_start:\.Ltmp.*]]:
38; ASM:         .cv_loc 0 1 9 9                 # t.cpp:9:9
39; ASM:         movl    $42, 40(%rsp)
40; ASM: [[inline_site1:\.Ltmp.*]]:
41; ASM:         .cv_inline_site_id 1 within 0 inlined_at 1 10 5
42; ASM:         .cv_loc 1 1 4 7                 # t.cpp:4:7
43; ASM:         movl    $3, 44(%rsp)
44; ASM:         leaq    44(%rsp), %rcx
45; ASM:         .cv_loc 1 1 5 3                 # t.cpp:5:3
46; ASM:         callq   capture
47; ASM:         leaq    40(%rsp), %rcx
48; ASM:         jmp     .LBB0_3
49; ASM: [[else_start:\.Ltmp.*]]:
50; ASM: .LBB0_2:                                # %if.else
51; ASM:         .cv_loc 0 1 13 9                # t.cpp:13:9
52; ASM:         movl    $42, 36(%rsp)
53; ASM: [[inline_site2:\.Ltmp.*]]:
54; ASM:         .cv_inline_site_id 2 within 0 inlined_at 1 14 5
55; ASM:         .cv_loc 2 1 4 7                 # t.cpp:4:7
56; ASM:         movl    $3, 48(%rsp)
57; ASM:         leaq    48(%rsp), %rcx
58; ASM:         .cv_loc 2 1 5 3                 # t.cpp:5:3
59; ASM:         callq   capture
60; ASM:         leaq    36(%rsp), %rcx
61; ASM: [[else_end:\.Ltmp.*]]:
62; ASM: .LBB0_3:                                # %if.end
63; ASM:         .cv_loc 0 1 0 0                # t.cpp:0:0
64; ASM:         callq   capture
65; ASM:         nop
66; ASM:         addq    $56, %rsp
67; ASM:         retq
68; ASM: [[param_end:\.Ltmp.*]]:
69
70; ASM: .short  4414                    # Record kind: S_LOCAL
71; ASM: .long   116                     # TypeIndex
72; ASM: .short  1                       # Flags
73; ASM: .asciz  "param"
74; ASM: .cv_def_range    [[prologue_end]] [[param_end]], "B\0214\000\000\000"
75; ASM: .short  4414                    # Record kind: S_LOCAL
76; ASM: .long   116                     # TypeIndex
77; ASM: .short  0                       # Flags
78; ASM: .asciz  "a"
79; ASM: .cv_def_range    [[if_start]] [[else_start]], "B\021(\000\000\000"
80; ASM: .short  4414                    # Record kind: S_LOCAL
81; ASM: .long   116                     # TypeIndex
82; ASM: .short  0                       # Flags
83; ASM: .asciz  "b"
84; ASM: .cv_def_range    [[else_start]] [[else_end]], "B\021$\000\000\000"
85; ASM: .short  4429                    # Record kind: S_INLINESITE
86; ASM: .short  4414                    # Record kind: S_LOCAL
87; ASM: .long   116                     # TypeIndex
88; ASM: .short  0                       # Flags
89; ASM: .asciz  "v"
90; ASM: .cv_def_range    [[inline_site1]] [[else_start]], "B\021,\000\000\000"
91; ASM: .short  4430                    # Record kind: S_INLINESITE_END
92; ASM: .short  4429                    # Record kind: S_INLINESITE
93; ASM: .short  4414                    # Record kind: S_LOCAL
94; ASM: .long   116                     # TypeIndex
95; ASM: .short  0                       # Flags
96; ASM: .asciz  "v"
97; ASM: .cv_def_range    [[inline_site2]] [[else_end]], "B\0210\000\000\000"
98; ASM: .short  4430                    # Record kind: S_INLINESITE_END
99
100; OBJ:  Subsection [
101; OBJ:    SubSectionType: Symbols (0xF1)
102; OBJ:    {{.*}}Proc{{.*}}Sym {
103; OBJ:      DisplayName: f
104; OBJ:      LinkageName: f
105; OBJ:    }
106; OBJ:    LocalSym {
107; OBJ:      Type: int (0x74)
108; OBJ:      Flags [ (0x1)
109; OBJ:        IsParameter (0x1)
110; OBJ:      ]
111; OBJ:      VarName: param
112; OBJ:    }
113; OBJ:    DefRangeFramePointerRelSym {
114; OBJ:      Offset: 52
115; OBJ:      LocalVariableAddrRange {
116; OBJ:        OffsetStart: .text+0x8
117; OBJ:        ISectStart: 0x0
118; OBJ:        Range: 0x4F
119; OBJ:      }
120; OBJ:    }
121; OBJ:    LocalSym {
122; OBJ:      Type: int (0x74)
123; OBJ:      Flags [ (0x0)
124; OBJ:      ]
125; OBJ:      VarName: a
126; OBJ:    }
127; OBJ:    DefRangeFramePointerRelSym {
128; OBJ:      Offset: 40
129; OBJ:      LocalVariableAddrRange {
130; OBJ:        OffsetStart: .text+0xC
131; OBJ:        ISectStart: 0x0
132; OBJ:        Range: 0x21
133; OBJ:      }
134; OBJ:    }
135; OBJ:    LocalSym {
136; OBJ:      Type: int (0x74)
137; OBJ:      Flags [ (0x0)
138; OBJ:      ]
139; OBJ:      VarName: b
140; OBJ:    }
141; OBJ:    DefRangeFramePointerRelSym {
142; OBJ:      Offset: 36
143; OBJ:      LocalVariableAddrRange {
144; OBJ:        OffsetStart: .text+0x2D
145; OBJ:        ISectStart: 0x0
146; OBJ:        Range: 0x1F
147; OBJ:      }
148; OBJ:    }
149; OBJ:    InlineSiteSym {
150; OBJ:      PtrParent: 0x0
151; OBJ:      PtrEnd: 0x0
152; OBJ:      Inlinee: will_be_inlined (0x1002)
153; OBJ:      BinaryAnnotations [
154; OBJ:        ChangeLineOffset: 1
155; OBJ:        ChangeCodeOffset: 0x14
156; OBJ:        ChangeCodeOffsetAndLineOffset: {CodeOffset: 0xD, LineOffset: 1}
157; OBJ:        ChangeCodeLength: 0xC
158; OBJ:      ]
159; OBJ:    }
160; OBJ:    LocalSym {
161; OBJ:      Type: int (0x74)
162; OBJ:      Flags [ (0x0)
163; OBJ:      ]
164; OBJ:      VarName: v
165; OBJ:    }
166; OBJ:    DefRangeFramePointerRelSym {
167; OBJ:      Offset: 44
168; OBJ:      LocalVariableAddrRange {
169; OBJ:        OffsetStart: .text+0x14
170; OBJ:        ISectStart: 0x0
171; OBJ:        Range: 0x19
172; OBJ:      }
173; OBJ:    }
174; OBJ:    InlineSiteEnd {
175; OBJ:    }
176; OBJ:    InlineSiteSym {
177; OBJ:      PtrParent: 0x0
178; OBJ:      PtrEnd: 0x0
179; OBJ:      Inlinee: will_be_inlined (0x1002)
180; OBJ:      BinaryAnnotations [
181; OBJ:        ChangeLineOffset: 1
182; OBJ:        ChangeCodeOffset: 0x35
183; OBJ:        ChangeCodeOffsetAndLineOffset: {CodeOffset: 0xD, LineOffset: 1}
184; OBJ:        ChangeCodeLength: 0xA
185; OBJ:      ]
186; OBJ:    }
187; OBJ:    LocalSym {
188; OBJ:      Type: int (0x74)
189; OBJ:      Flags [ (0x0)
190; OBJ:      ]
191; OBJ:      VarName: v
192; OBJ:    }
193; OBJ:    DefRangeFramePointerRelSym {
194; OBJ:      Offset: 48
195; OBJ:      LocalVariableAddrRange {
196; OBJ:        OffsetStart: .text+0x35
197; OBJ:        ISectStart: 0x0
198; OBJ:        Range: 0x17
199; OBJ:      }
200; OBJ:    }
201; OBJ:    InlineSiteEnd {
202; OBJ:    }
203; OBJ:    ProcEnd
204; OBJ:  ]
205
206; ModuleID = 't.cpp'
207target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
208target triple = "x86_64-pc-windows-msvc18.0.0"
209
210; Function Attrs: nounwind uwtable
211define void @f(i32 %param) #0 !dbg !4 {
212entry:
213  %v.i1 = alloca i32, align 4
214  call void @llvm.dbg.declare(metadata i32* %v.i1, metadata !15, metadata !16), !dbg !17
215  %v.i = alloca i32, align 4
216  call void @llvm.dbg.declare(metadata i32* %v.i, metadata !15, metadata !16), !dbg !21
217  %param.addr = alloca i32, align 4
218  %a = alloca i32, align 4
219  %b = alloca i32, align 4
220  store i32 %param, i32* %param.addr, align 4
221  call void @llvm.dbg.declare(metadata i32* %param.addr, metadata !24, metadata !16), !dbg !25
222  %0 = load i32, i32* %param.addr, align 4, !dbg !26
223  %tobool = icmp ne i32 %0, 0, !dbg !26
224  br i1 %tobool, label %if.then, label %if.else, !dbg !27
225
226if.then:                                          ; preds = %entry
227  call void @llvm.dbg.declare(metadata i32* %a, metadata !28, metadata !16), !dbg !29
228  store i32 42, i32* %a, align 4, !dbg !29
229  store i32 3, i32* %v.i, align 4, !dbg !21
230  call void @capture(i32* %v.i) #3, !dbg !30
231  call void @capture(i32* %a), !dbg !31
232  br label %if.end, !dbg !32
233
234if.else:                                          ; preds = %entry
235  call void @llvm.dbg.declare(metadata i32* %b, metadata !33, metadata !16), !dbg !34
236  store i32 42, i32* %b, align 4, !dbg !34
237  store i32 3, i32* %v.i1, align 4, !dbg !17
238  call void @capture(i32* %v.i1) #3, !dbg !35
239  call void @capture(i32* %b), !dbg !36
240  br label %if.end
241
242if.end:                                           ; preds = %if.else, %if.then
243  ret void, !dbg !37
244}
245
246; Function Attrs: nounwind readnone
247declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
248
249declare void @capture(i32*) #2
250
251attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
252attributes #1 = { nounwind readnone }
253attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
254attributes #3 = { nounwind }
255
256!llvm.dbg.cu = !{!0}
257!llvm.module.flags = !{!11, !12, !13}
258!llvm.ident = !{!14}
259
260!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
261!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
262!2 = !{}
263!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
264!5 = !DISubroutineType(types: !6)
265!6 = !{null, !7}
266!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
267!8 = distinct !DISubprogram(name: "will_be_inlined", linkageName: "\01?will_be_inlined@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
268!9 = !DISubroutineType(types: !10)
269!10 = !{null}
270!11 = !{i32 2, !"CodeView", i32 1}
271!12 = !{i32 2, !"Debug Info Version", i32 3}
272!13 = !{i32 1, !"PIC Level", i32 2}
273!14 = !{!"clang version 3.9.0 "}
274!15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7)
275!16 = !DIExpression()
276!17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18)
277!18 = distinct !DILocation(line: 14, column: 5, scope: !19)
278!19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 12, column: 10)
279!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
280!21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22)
281!22 = distinct !DILocation(line: 10, column: 5, scope: !23)
282!23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14)
283!24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7)
284!25 = !DILocation(line: 7, column: 23, scope: !4)
285!26 = !DILocation(line: 8, column: 7, scope: !20)
286!27 = !DILocation(line: 8, column: 7, scope: !4)
287!28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7)
288!29 = !DILocation(line: 9, column: 9, scope: !23)
289!30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22)
290!31 = !DILocation(line: 11, column: 5, scope: !23)
291!32 = !DILocation(line: 12, column: 3, scope: !23)
292!33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7)
293!34 = !DILocation(line: 13, column: 9, scope: !19)
294!35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18)
295!36 = !DILocation(line: 15, column: 5, scope: !19)
296!37 = !DILocation(line: 17, column: 1, scope: !4)
297