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