1; RUN: llc -O0 < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DEBUG 2; RUN: llc < %s | FileCheck %s 3; RUN: llc -filetype=obj -O0 < %s | llvm-readobj -codeview - | FileCheck %s --check-prefix=OBJ 4 5; IR generated by the following source: 6; struct NonTrivial { 7; NonTrivial();// : x(42) {} 8; ~NonTrivial();// {} 9; int x; 10; }; 11; extern "C" void g(int);// {} 12; extern "C" void h(int);// {} 13; extern "C" void f(NonTrivial a, int b, int unused, int c) { 14; if (b) { 15; g(c); 16; } else { 17; h(a.x); 18; } 19; (void)unused; 20; } 21; //int main() { 22; // NonTrivial x; 23; // f(x, 1, 2, 3); 24; //} 25; 26; Remove C++ comments to have a complete, debuggable program. 27 28; We don't need (or want) DBG_VALUE instructions to describe the location of 29; inalloca arguments. We want frame indices in the side table, especially at 30; -O0, because they are reliable across the entire function and don't require 31; any propagation or analysis. 32 33; CHECK: _f: # @f 34; CHECK: Lfunc_begin0: 35; CHECK-NOT: DEBUG_VALUE 36; CHECK: [[start:Ltmp[0-9]+]]: 37; CHECK-NOT: DEBUG_VALUE 38; CHECK: cmpl 39; CHECK: calll _g 40; CHECK: calll _h 41; CHECK: jmp "??1NonTrivial@@QAE@XZ" 42; CHECK: [[end:Ltmp[0-9]+]]: 43; CHECK: Lfunc_end0: 44 45; FIXME: Optimized debug info should preserve this. 46; DEBUG: .short 4414 # Record kind: S_LOCAL 47; DEBUG: .asciz "a" 48; DEBUG: .cv_def_range [[start]] [[end]] 49 50; CHECK: .short 4414 # Record kind: S_LOCAL 51; CHECK: .asciz "b" 52; CHECK: .cv_def_range [[start]] [[end]] 53 54; CHECK: .short 4414 # Record kind: S_LOCAL 55; CHECK: .asciz "c" 56; CHECK: .cv_def_range [[start]] [[end]] 57 58; OBJ-LABEL: {{.*}}Proc{{.*}}Sym { 59; OBJ: Kind: S_GPROC32_ID (0x1147) 60; OBJ: DisplayName: f 61; OBJ: } 62; OBJ: LocalSym { 63; OBJ: Type: NonTrivial (0x1007) 64; OBJ: Flags [ (0x1) 65; OBJ: IsParameter (0x1) 66; OBJ: ] 67; OBJ: VarName: a 68; OBJ: } 69; OBJ: DefRangeRegisterRelSym { 70; OBJ: BaseRegister: CVRegESP (0x15) 71; OBJ: BasePointerOffset: 12 72; OBJ: } 73; OBJ: LocalSym { 74; OBJ: Type: int (0x74) 75; OBJ: Flags [ (0x1) 76; OBJ: IsParameter (0x1) 77; OBJ: ] 78; OBJ: VarName: b 79; OBJ: } 80; OBJ: DefRangeRegisterRelSym { 81; OBJ: BaseRegister: CVRegESP (0x15) 82; OBJ: BasePointerOffset: 16 83; OBJ: } 84; FIXME: Retain unused. 85; OBJ: LocalSym { 86; OBJ: Type: int (0x74) 87; OBJ: Flags [ (0x1) 88; OBJ: IsParameter (0x1) 89; OBJ: ] 90; OBJ: VarName: c 91; OBJ: } 92; OBJ: DefRangeRegisterRelSym { 93; OBJ: BaseRegister: CVRegESP (0x15) 94; OBJ: BasePointerOffset: 24 95; OBJ: } 96; OBJ-LABEL: ProcEnd { 97; OBJ: } 98 99 100; ModuleID = 't.cpp' 101source_filename = "t.cpp" 102target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 103target triple = "i386-pc-windows-msvc19.10.24728" 104 105%struct.NonTrivial = type { i32 } 106 107; Function Attrs: nounwind 108define void @f(<{ %struct.NonTrivial, i32, i32, i32 }>* inalloca) local_unnamed_addr #0 !dbg !7 { 109entry: 110 %a = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0 111 %b = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 1 112 tail call void @llvm.dbg.declare(metadata i32* %c, metadata !20, metadata !24), !dbg !25 113 tail call void @llvm.dbg.declare(metadata i32* %b, metadata !22, metadata !24), !dbg !26 114 tail call void @llvm.dbg.declare(metadata %struct.NonTrivial* %a, metadata !23, metadata !24), !dbg !27 115 %1 = load i32, i32* %b, align 4, !dbg !28, !tbaa !30 116 %tobool = icmp eq i32 %1, 0, !dbg !28 117 br i1 %tobool, label %if.else, label %if.then, !dbg !34 118 119if.then: ; preds = %entry 120 %c = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 3 121 %2 = load i32, i32* %c, align 4, !dbg !35, !tbaa !30 122 tail call void @g(i32 %2) #4, !dbg !37 123 br label %if.end, !dbg !38 124 125if.else: ; preds = %entry 126 %x = getelementptr inbounds <{ %struct.NonTrivial, i32, i32, i32 }>, <{ %struct.NonTrivial, i32, i32, i32 }>* %0, i32 0, i32 0, i32 0, !dbg !39 127 %3 = load i32, i32* %x, align 4, !dbg !39, !tbaa !41 128 tail call void @h(i32 %3) #4, !dbg !43 129 br label %if.end 130 131if.end: ; preds = %if.else, %if.then 132 tail call x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial* nonnull %a) #4, !dbg !44 133 ret void, !dbg !44 134} 135 136; Function Attrs: nounwind readnone speculatable 137declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 138 139declare void @g(i32) local_unnamed_addr 140 141declare void @h(i32) local_unnamed_addr 142 143; Function Attrs: nounwind 144declare x86_thiscallcc void @"\01??1NonTrivial@@QAE@XZ"(%struct.NonTrivial*) unnamed_addr #3 145 146attributes #0 = { nounwind } 147attributes #1 = { nounwind readnone speculatable } 148attributes #3 = { nounwind } 149attributes #4 = { nounwind } 150 151!llvm.dbg.cu = !{!0} 152!llvm.module.flags = !{!3, !4, !5} 153!llvm.ident = !{!6} 154 155!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 156!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "e41e3fda2a91b52e121ed6c29a209eae") 157!2 = !{} 158!3 = !{i32 1, !"NumRegisterParameters", i32 0} 159!4 = !{i32 2, !"CodeView", i32 1} 160!5 = !{i32 2, !"Debug Info Version", i32 3} 161!6 = !{!"clang version 5.0.0 "} 162!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !8, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !19) 163!8 = !DISubroutineType(types: !9) 164!9 = !{null, !10, !13, !13, !13} 165!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NonTrivial", file: !1, line: 1, size: 32, elements: !11, identifier: ".?AUNonTrivial@@") 166!11 = !{!12, !14, !18} 167!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !10, file: !1, line: 4, baseType: !13, size: 32) 168!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 169!14 = !DISubprogram(name: "NonTrivial", scope: !10, file: !1, line: 2, type: !15, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true) 170!15 = !DISubroutineType(cc: DW_CC_BORLAND_thiscall, types: !16) 171!16 = !{null, !17} 172!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, flags: DIFlagArtificial | DIFlagObjectPointer) 173!18 = !DISubprogram(name: "~NonTrivial", scope: !10, file: !1, line: 3, type: !15, isLocal: false, isDefinition: false, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true) 174!19 = !{!20, !21, !22, !23} 175!20 = !DILocalVariable(name: "c", arg: 4, scope: !7, file: !1, line: 8, type: !13) 176!21 = !DILocalVariable(name: "unused", arg: 3, scope: !7, file: !1, line: 8, type: !13) 177!22 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 8, type: !13) 178!23 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 8, type: !10) 179!24 = !DIExpression() 180!25 = !DILocation(line: 8, column: 56, scope: !7) 181!26 = !DILocation(line: 8, column: 37, scope: !7) 182!27 = !DILocation(line: 8, column: 30, scope: !7) 183!28 = !DILocation(line: 9, column: 7, scope: !29) 184!29 = distinct !DILexicalBlock(scope: !7, file: !1, line: 9, column: 7) 185!30 = !{!31, !31, i64 0} 186!31 = !{!"int", !32, i64 0} 187!32 = !{!"omnipotent char", !33, i64 0} 188!33 = !{!"Simple C++ TBAA"} 189!34 = !DILocation(line: 9, column: 7, scope: !7) 190!35 = !DILocation(line: 10, column: 7, scope: !36) 191!36 = distinct !DILexicalBlock(scope: !29, file: !1, line: 9, column: 10) 192!37 = !DILocation(line: 10, column: 5, scope: !36) 193!38 = !DILocation(line: 11, column: 3, scope: !36) 194!39 = !DILocation(line: 12, column: 9, scope: !40) 195!40 = distinct !DILexicalBlock(scope: !29, file: !1, line: 11, column: 10) 196!41 = !{!42, !31, i64 0} 197!42 = !{!"?AUNonTrivial@@", !31, i64 0} 198!43 = !DILocation(line: 12, column: 5, scope: !40) 199!44 = !DILocation(line: 15, column: 1, scope: !7) 200