1; RUN: llc < %s | FileCheck %s --check-prefix=ASM
2; RUN: llc < %s -filetype=obj | llvm-readobj -codeview - | FileCheck %s --check-prefix=OBJ
3
4; Generated from:
5; volatile int x;
6; int getint(void);
7; void putint(int);
8; static inline int inlineinc(int a) {
9;   int b = a + 1;
10;   ++x;
11;   return b;
12; }
13; void f(int p) {
14;   if (p) {
15;     int a = getint();
16;     int b = inlineinc(a);
17;     putint(b);
18;   } else {
19;     int c = getint();
20;     putint(c);
21;   }
22; }
23
24; ASM: f:                                      # @f
25; ASM: .Lfunc_begin0:
26; ASM: # BB#0:                                 # %entry
27; ASM:         pushq   %rsi
28; ASM:         subq    $32, %rsp
29; ASM:         #DEBUG_VALUE: f:p <- %ECX
30; ASM:         movl    %ecx, %esi
31; ASM: [[p_ecx_esi:\.Ltmp.*]]:
32; ASM:         #DEBUG_VALUE: f:p <- %ESI
33; ASM:         callq   getint
34; ASM: [[after_getint:\.Ltmp.*]]:
35; ASM:         #DEBUG_VALUE: a <- %EAX
36; ASM:         #DEBUG_VALUE: inlineinc:a <- %EAX
37; ASM:         #DEBUG_VALUE: c <- %EAX
38; ASM:         testl   %esi, %esi
39; ASM:         je      .LBB0_2
40; ASM: # BB#1:                                 # %if.then
41; ASM-DAG:     #DEBUG_VALUE: c <- %EAX
42; ASM-DAG:     #DEBUG_VALUE: inlineinc:a <- %EAX
43; ASM-DAG:     #DEBUG_VALUE: a <- %EAX
44; ASM-DAG:     #DEBUG_VALUE: f:p <- %ESI
45; ASM:         incl    %eax
46; ASM: [[after_inc_eax:\.Ltmp.*]]:
47; ASM:         #DEBUG_VALUE: inlineinc:b <- %EAX
48; ASM:         #DEBUG_VALUE: b <- %EAX
49; ASM:         incl    x(%rip)
50; ASM: [[after_if:\.Ltmp.*]]:
51; ASM: .LBB0_2:                                # %if.else
52; ASM:         #DEBUG_VALUE: f:p <- %ESI
53; ASM:         movl    %eax, %ecx
54; ASM:         addq    $32, %rsp
55; ASM:         popq    %rsi
56; ASM: [[func_end:\.Ltmp.*]]:
57; ASM:         rex64 jmp       putint          # TAILCALL
58
59; ASM:         .short  4414                    # Record kind: S_LOCAL
60; ASM:         .asciz  "p"
61; ASM:         .cv_def_range    .Lfunc_begin0 [[p_ecx_esi]], "A\021\022\000\000\000"
62; ASM:         .cv_def_range    [[p_ecx_esi]] [[func_end]], "A\021\027\000\000\000"
63; ASM:         .short  4414                    # Record kind: S_LOCAL
64; ASM:         .asciz  "a"
65; ASM:         .cv_def_range    [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000"
66; ASM:         .short  4414                    # Record kind: S_LOCAL
67; ASM:         .asciz  "c"
68; ASM:         .cv_def_range    [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000"
69; ASM:         .short  4414                    # Record kind: S_LOCAL
70; ASM:         .asciz  "b"
71; ASM:         .cv_def_range    [[after_inc_eax]] [[after_if]], "A\021\021\000\000\000"
72
73; ASM:         .short  4429                    # Record kind: S_INLINESITE
74; ASM:         .short  4414                    # Record kind: S_LOCAL
75; ASM:         .asciz  "a"
76; ASM:         .cv_def_range    [[after_getint]] [[after_inc_eax]], "A\021\021\000\000\000"
77; ASM:         .short  4414                    # Record kind: S_LOCAL
78; ASM:         .asciz  "b"
79; ASM:         .cv_def_range    [[after_inc_eax]] [[after_if]], "A\021\021\000\000\000"
80; ASM:         .short  4430                    # Record kind: S_INLINESITE_END
81
82; OBJ: Subsection [
83; OBJ:   SubSectionType: Symbols (0xF1)
84; OBJ:   ProcStart {
85; OBJ:     DisplayName: f
86; OBJ:   }
87; OBJ:   Local {
88; OBJ:     Type: int (0x74)
89; OBJ:     Flags [ (0x1)
90; OBJ:       IsParameter (0x1)
91; OBJ:     ]
92; OBJ:     VarName: p
93; OBJ:   }
94; OBJ:   DefRangeRegister {
95; OBJ:     Register: 18
96; OBJ:     LocalVariableAddrRange {
97; OBJ:       OffsetStart: .text+0x0
98; OBJ:       ISectStart: 0x0
99; OBJ:       Range: 0x7
100; OBJ:     }
101; OBJ:   }
102; OBJ:   DefRangeRegister {
103; OBJ:     Register: 23
104; OBJ:     LocalVariableAddrRange {
105; OBJ:       OffsetStart: .text+0x7
106; OBJ:       ISectStart: 0x0
107; OBJ:       Range: 0x18
108; OBJ:     }
109; OBJ:   }
110; OBJ:   Local {
111; OBJ:     Type: int (0x74)
112; OBJ:     Flags [ (0x0)
113; OBJ:     ]
114; OBJ:     VarName: a
115; OBJ:   }
116; OBJ:   DefRangeRegister {
117; OBJ:     Register: 17
118; OBJ:     LocalVariableAddrRange {
119; OBJ:       OffsetStart: .text+0xC
120; OBJ:       ISectStart: 0x0
121; OBJ:       Range: 0x6
122; OBJ:     }
123; OBJ:   }
124; OBJ:   Local {
125; OBJ:     Type: int (0x74)
126; OBJ:     Flags [ (0x0)
127; OBJ:     ]
128; OBJ:     VarName: c
129; OBJ:   }
130; OBJ:   DefRangeRegister {
131; OBJ:     Register: 17
132; OBJ:     LocalVariableAddrRange {
133; OBJ:       OffsetStart: .text+0xC
134; OBJ:       ISectStart: 0x0
135; OBJ:       Range: 0x6
136; OBJ:     }
137; OBJ:   }
138; OBJ:   Local {
139; OBJ:     Type: int (0x74)
140; OBJ:     Flags [ (0x0)
141; OBJ:     ]
142; OBJ:     VarName: b
143; OBJ:   }
144; OBJ:   DefRangeRegister {
145; OBJ:     Register: 17
146; OBJ:     LocalVariableAddrRange {
147; OBJ:       OffsetStart: .text+0x12
148; OBJ:       ISectStart: 0x0
149; OBJ:       Range: 0x6
150; OBJ:     }
151; OBJ:   }
152; OBJ:   InlineSite {
153; OBJ:     PtrParent: 0x0
154; OBJ:     PtrEnd: 0x0
155; OBJ:     Inlinee: inlineinc (0x1002)
156; OBJ:   }
157; OBJ:   Local {
158; OBJ:     Type: int (0x74)
159; OBJ:     Flags [ (0x1)
160; OBJ:       IsParameter (0x1)
161; OBJ:     ]
162; OBJ:     VarName: a
163; OBJ:   }
164; OBJ:   DefRangeRegister {
165; OBJ:     Register: 17
166; OBJ:     LocalVariableAddrRange {
167; OBJ:       OffsetStart: .text+0xC
168; OBJ:       ISectStart: 0x0
169; OBJ:       Range: 0x6
170; OBJ:     }
171; OBJ:   }
172; OBJ:   Local {
173; OBJ:     Type: int (0x74)
174; OBJ:     Flags [ (0x0)
175; OBJ:     ]
176; OBJ:     VarName: b
177; OBJ:   }
178; OBJ:   DefRangeRegister {
179; OBJ:     Register: 17
180; OBJ:     LocalVariableAddrRange {
181; OBJ:       OffsetStart: .text+0x12
182; OBJ:       ISectStart: 0x0
183; OBJ:       Range: 0x6
184; OBJ:     }
185; OBJ:   }
186; OBJ:   InlineSiteEnd {
187; OBJ:   }
188; OBJ:   ProcEnd
189; OBJ: ]
190
191; ModuleID = 't.cpp'
192target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
193target triple = "x86_64-pc-windows-msvc18.0.0"
194
195@x = internal global i32 0, align 4
196
197; Function Attrs: nounwind uwtable
198define void @f(i32 %p) #0 !dbg !4 {
199entry:
200  tail call void @llvm.dbg.value(metadata i32 %p, i64 0, metadata !9, metadata !29), !dbg !30
201  %tobool = icmp eq i32 %p, 0, !dbg !31
202  %call2 = tail call i32 @getint() #3, !dbg !32
203  br i1 %tobool, label %if.else, label %if.then, !dbg !33
204
205if.then:                                          ; preds = %entry
206  tail call void @llvm.dbg.value(metadata i32 %call2, i64 0, metadata !10, metadata !29), !dbg !34
207  tail call void @llvm.dbg.value(metadata i32 %call2, i64 0, metadata !20, metadata !29), !dbg !35
208  %add.i = add nsw i32 %call2, 1, !dbg !37
209  tail call void @llvm.dbg.value(metadata i32 %add.i, i64 0, metadata !21, metadata !29), !dbg !38
210  %0 = load volatile i32, i32* @x, align 4, !dbg !39, !tbaa !40
211  %inc.i = add nsw i32 %0, 1, !dbg !39
212  store volatile i32 %inc.i, i32* @x, align 4, !dbg !39, !tbaa !40
213  tail call void @llvm.dbg.value(metadata i32 %add.i, i64 0, metadata !13, metadata !29), !dbg !44
214  tail call void @putint(i32 %add.i) #3, !dbg !45
215  br label %if.end, !dbg !46
216
217if.else:                                          ; preds = %entry
218  tail call void @llvm.dbg.value(metadata i32 %call2, i64 0, metadata !14, metadata !29), !dbg !47
219  tail call void @putint(i32 %call2) #3, !dbg !48
220  br label %if.end
221
222if.end:                                           ; preds = %if.else, %if.then
223  ret void, !dbg !49
224}
225
226declare i32 @getint() #1
227
228declare void @putint(i32) #1
229
230; Function Attrs: nounwind readnone
231declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
232
233attributes #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" }
234attributes #1 = { "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" }
235attributes #2 = { nounwind readnone }
236attributes #3 = { nounwind }
237
238!llvm.dbg.cu = !{!0}
239!llvm.module.flags = !{!25, !26, !27}
240!llvm.ident = !{!28}
241
242!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 260617) (llvm/trunk 260619)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !22)
243!1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
244!2 = !{}
245!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 9, type: !5, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !8)
246!5 = !DISubroutineType(types: !6)
247!6 = !{null, !7}
248!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
249!8 = !{!9, !10, !13, !14}
250!9 = !DILocalVariable(name: "p", arg: 1, scope: !4, file: !1, line: 9, type: !7)
251!10 = !DILocalVariable(name: "a", scope: !11, file: !1, line: 11, type: !7)
252!11 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10, column: 10)
253!12 = distinct !DILexicalBlock(scope: !4, file: !1, line: 10, column: 7)
254!13 = !DILocalVariable(name: "b", scope: !11, file: !1, line: 12, type: !7)
255!14 = !DILocalVariable(name: "c", scope: !15, file: !1, line: 15, type: !7)
256!15 = distinct !DILexicalBlock(scope: !12, file: !1, line: 14, column: 10)
257!16 = distinct !DISubprogram(name: "inlineinc", scope: !1, file: !1, line: 4, type: !17, isLocal: true, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !19)
258!17 = !DISubroutineType(types: !18)
259!18 = !{!7, !7}
260!19 = !{!20, !21}
261!20 = !DILocalVariable(name: "a", arg: 1, scope: !16, file: !1, line: 4, type: !7)
262!21 = !DILocalVariable(name: "b", scope: !16, file: !1, line: 5, type: !7)
263!22 = !{!23}
264!23 = !DIGlobalVariable(name: "x", scope: !0, file: !1, line: 1, type: !24, isLocal: false, isDefinition: true, variable: i32* @x)
265!24 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)
266!25 = !{i32 2, !"CodeView", i32 1}
267!26 = !{i32 2, !"Debug Info Version", i32 3}
268!27 = !{i32 1, !"PIC Level", i32 2}
269!28 = !{!"clang version 3.9.0 (trunk 260617) (llvm/trunk 260619)"}
270!29 = !DIExpression()
271!30 = !DILocation(line: 9, column: 12, scope: !4)
272!31 = !DILocation(line: 10, column: 7, scope: !12)
273!32 = !DILocation(line: 15, column: 13, scope: !15)
274!33 = !DILocation(line: 10, column: 7, scope: !4)
275!34 = !DILocation(line: 11, column: 9, scope: !11)
276!35 = !DILocation(line: 4, column: 33, scope: !16, inlinedAt: !36)
277!36 = distinct !DILocation(line: 12, column: 13, scope: !11)
278!37 = !DILocation(line: 5, column: 13, scope: !16, inlinedAt: !36)
279!38 = !DILocation(line: 5, column: 7, scope: !16, inlinedAt: !36)
280!39 = !DILocation(line: 6, column: 3, scope: !16, inlinedAt: !36)
281!40 = !{!41, !41, i64 0}
282!41 = !{!"int", !42, i64 0}
283!42 = !{!"omnipotent char", !43, i64 0}
284!43 = !{!"Simple C/C++ TBAA"}
285!44 = !DILocation(line: 12, column: 9, scope: !11)
286!45 = !DILocation(line: 13, column: 5, scope: !11)
287!46 = !DILocation(line: 14, column: 3, scope: !11)
288!47 = !DILocation(line: 15, column: 9, scope: !15)
289!48 = !DILocation(line: 16, column: 5, scope: !15)
290!49 = !DILocation(line: 18, column: 1, scope: !4)
291