1; RUN: opt %s -S -passes=sroa -o - | FileCheck %s 2; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=sroa -o - | FileCheck %s 3 4;; Check that SROA preserves the InlinedAt status of new dbg.assign intriniscs 5;; it inserts. 6 7;; $cat test.c 8;; typedef struct { 9;; int a; 10;; int b[]; 11;; } c; 12;; int d, e, f; 13;; void g(c *h) { 14;; if (d) 15;; h->a = 1; 16;; } 17;; void i(c *h) { 18;; long j = f = 0; 19;; for (; f < h->a; f++) 20;; j += h->b[f]; 21;; e = j; 22;; } 23;; void k() { 24;; c j; 25;; g(&j); 26;; i(&j); 27;; } 28;; void l() { k(); } 29;; 30;; $ clang test.c -Xclang -fexperimental-assignment-tracking -O2 -g 31 32; CHECK: #dbg_assign(i1 false, !{{.+}}, !DIExpression(), !{{.+}}, ptr undef, !DIExpression(), ![[DBG:[0-9]+]] 33 34; CHECK-DAG: ![[DBG]] = !DILocation(line: 0, scope: ![[INL_SC:[0-9]+]], inlinedAt: ![[IA:[0-9]+]]) 35; CHECK-DAG: ![[IA]] = distinct !DILocation(line: 21, column: 12, scope: ![[SC:[0-9]+]]) 36; CHECK-DAG: ![[SC]] = distinct !DISubprogram(name: "l", 37; CHECK-DAG: ![[INL_SC]] = distinct !DISubprogram(name: "k" 38 39%struct.c = type { i32, [0 x i32] } 40 41@f = dso_local local_unnamed_addr global i32 0, align 4, !dbg !9 42@e = dso_local local_unnamed_addr global i32 0, align 4, !dbg !6 43 44declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1 45declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2 46declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2 47 48define dso_local void @l() local_unnamed_addr #4 !dbg !73 { 49entry: 50 %j.i = alloca %struct.c, align 4, !DIAssignID !74 51 ; NOTE: this has been changed from undef to false so that the intrinsic isn't 52 ; deleted as redundant. 53 call void @llvm.dbg.assign(metadata i1 false, metadata !64, metadata !DIExpression(), metadata !74, metadata ptr %j.i, metadata !DIExpression()) #5, !dbg !75 54 %0 = bitcast ptr %j.i to ptr, !dbg !77 55 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #5, !dbg !77 56 %arrayidx.i.i = getelementptr inbounds %struct.c, ptr %j.i, i64 0, i32 1, i64 0, !dbg !78 57 %1 = load i32, ptr %arrayidx.i.i, align 4, !dbg !78 58 store i32 1, ptr @f, align 4, !dbg !80 59 store i32 %1, ptr @e, align 4, !dbg !81 60 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #5, !dbg !82 61 ret void, !dbg !83 62} 63 64!llvm.dbg.cu = !{!2} 65!llvm.module.flags = !{!11, !12, !13, !1000} 66!llvm.ident = !{!14} 67 68!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 69!1 = distinct !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true) 70!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) 71!3 = !DIFile(filename: "test.c", directory: "/") 72!4 = !{} 73!5 = !{!0, !6, !9} 74!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression()) 75!7 = distinct !DIGlobalVariable(name: "e", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true) 76!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 77!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) 78!10 = distinct !DIGlobalVariable(name: "f", scope: !2, file: !3, line: 5, type: !8, isLocal: false, isDefinition: true) 79!11 = !{i32 7, !"Dwarf Version", i32 4} 80!12 = !{i32 2, !"Debug Info Version", i32 3} 81!13 = !{i32 1, !"wchar_size", i32 4} 82!14 = !{!"clang version 12.0.0)"} 83!15 = distinct !DISubprogram(name: "g", scope: !3, file: !3, line: 6, type: !16, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !27) 84!16 = !DISubroutineType(types: !17) 85!17 = !{null, !18} 86!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) 87!19 = !DIDerivedType(tag: DW_TAG_typedef, name: "c", file: !3, line: 4, baseType: !20) 88!20 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 1, size: 32, elements: !21) 89!21 = !{!22, !23} 90!22 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !20, file: !3, line: 2, baseType: !8, size: 32) 91!23 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !20, file: !3, line: 3, baseType: !24, offset: 32) 92!24 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, elements: !25) 93!25 = !{!26} 94!26 = !DISubrange(count: -1) 95!27 = !{!28} 96!28 = !DILocalVariable(name: "h", arg: 1, scope: !15, file: !3, line: 6, type: !18) 97!29 = !DILocation(line: 7, column: 7, scope: !30) 98!30 = distinct !DILexicalBlock(scope: !15, file: !3, line: 7, column: 7) 99!35 = !DILocation(line: 7, column: 7, scope: !15) 100!36 = !DILocation(line: 8, column: 8, scope: !30) 101!37 = !DILocation(line: 8, column: 10, scope: !30) 102!38 = !DILocation(line: 8, column: 5, scope: !30) 103!39 = !DILocation(line: 9, column: 1, scope: !15) 104!40 = distinct !DISubprogram(name: "i", scope: !3, file: !3, line: 10, type: !16, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !41) 105!41 = !{!42, !43} 106!42 = !DILocalVariable(name: "h", arg: 1, scope: !40, file: !3, line: 10, type: !18) 107!43 = !DILocalVariable(name: "j", scope: !40, file: !3, line: 11, type: !44) 108!44 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) 109!45 = !DILocation(line: 0, scope: !40) 110!46 = !DILocation(line: 12, column: 17, scope: !47) 111!47 = distinct !DILexicalBlock(scope: !48, file: !3, line: 12, column: 3) 112!48 = distinct !DILexicalBlock(scope: !40, file: !3, line: 12, column: 3) 113!49 = !DILocation(line: 12, column: 12, scope: !47) 114!50 = !DILocation(line: 12, column: 3, scope: !48) 115!51 = !DILocation(line: 13, column: 10, scope: !47) 116!52 = !DILocation(line: 13, column: 7, scope: !47) 117!53 = !DILocation(line: 12, column: 21, scope: !47) 118!54 = distinct !{!54, !50, !55, !56} 119!55 = !DILocation(line: 13, column: 16, scope: !48) 120!56 = !{!"llvm.loop.mustprogress"} 121!57 = !DILocation(line: 14, column: 7, scope: !40) 122!58 = !DILocation(line: 14, column: 5, scope: !40) 123!59 = !DILocation(line: 15, column: 1, scope: !40) 124!60 = distinct !DISubprogram(name: "k", scope: !3, file: !3, line: 16, type: !61, scopeLine: 16, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !63) 125!61 = !DISubroutineType(types: !62) 126!62 = !{null} 127!63 = !{!64} 128!64 = !DILocalVariable(name: "j", scope: !60, file: !3, line: 17, type: !19) 129!65 = distinct !DIAssignID() 130!66 = !DILocation(line: 0, scope: !60) 131!67 = !DILocation(line: 17, column: 3, scope: !60) 132!68 = !DILocation(line: 13, column: 10, scope: !47, inlinedAt: !69) 133!69 = distinct !DILocation(line: 19, column: 3, scope: !60) 134!70 = !DILocation(line: 0, scope: !40, inlinedAt: !69) 135!71 = !DILocation(line: 14, column: 5, scope: !40, inlinedAt: !69) 136!72 = !DILocation(line: 20, column: 1, scope: !60) 137!73 = distinct !DISubprogram(name: "l", scope: !3, file: !3, line: 21, type: !61, scopeLine: 21, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) 138!74 = distinct !DIAssignID() 139!75 = !DILocation(line: 0, scope: !60, inlinedAt: !76) 140!76 = distinct !DILocation(line: 21, column: 12, scope: !73) 141!77 = !DILocation(line: 17, column: 3, scope: !60, inlinedAt: !76) 142!78 = !DILocation(line: 13, column: 10, scope: !47, inlinedAt: !79) 143!79 = distinct !DILocation(line: 19, column: 3, scope: !60, inlinedAt: !76) 144!80 = !DILocation(line: 0, scope: !40, inlinedAt: !79) 145!81 = !DILocation(line: 14, column: 5, scope: !40, inlinedAt: !79) 146!82 = !DILocation(line: 20, column: 1, scope: !60, inlinedAt: !76) 147!83 = !DILocation(line: 21, column: 17, scope: !73) 148!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true} 149