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