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