xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/sroa/frag.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
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;; $ cat test.cpp
5;; class c {
6;;   float b[4];
7;; };
8;; c fn1();
9;; void d() {
10;;   c a[3];
11;;   a[2] = fn1();
12;; }
13;;
14;; Generated by grabbing IR before sroa in:
15;; $ clang++ -O2 -g -c test.cpp -Xclang -fexperimental-assignment-tracking
16;;
17;; Check that when the memcpy to fragment(256, 128) is split into two 2xfloat
18;; stores, the dbg.assign is split into two with fragment(256, 64) &
19;; fragment(320, 64). Ensure that only the value-expression gets fragment info;
20;; that the address-expression remains untouched.
21
22; CHECK: %call = call
23; CHECK-NEXT: %0 = extractvalue { <2 x float>, <2 x float> } %call, 0
24; CHECK-NEXT: %1 = extractvalue { <2 x float>, <2 x float> } %call, 1
25; CHECK-NEXT: #dbg_value(<2 x float> %0, ![[var:[0-9]+]], !DIExpression(DW_OP_LLVM_fragment, 256, 64),
26; CHECK-NEXT: #dbg_value(<2 x float> %1, ![[var]], !DIExpression(DW_OP_LLVM_fragment, 320, 64),
27
28%class.c = type { [4 x float] }
29
30; Function Attrs: uwtable
31define dso_local void @_Z1dv() #0 !dbg !7 {
32entry:
33  %a = alloca [3 x %class.c], align 16, !DIAssignID !22
34  call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(), metadata !22, metadata ptr %a, metadata !DIExpression()), !dbg !23
35  %ref.tmp = alloca %class.c, align 4
36  %0 = bitcast ptr %a to ptr, !dbg !24
37  call void @llvm.lifetime.start.p0(i64 48, ptr %0) #4, !dbg !24
38  %1 = bitcast ptr %ref.tmp to ptr, !dbg !25
39  call void @llvm.lifetime.start.p0(i64 16, ptr %1) #4, !dbg !25
40  %call = call { <2 x float>, <2 x float> } @_Z3fn1v(), !dbg !25
41  %coerce.dive = getelementptr inbounds %class.c, ptr %ref.tmp, i32 0, i32 0, !dbg !25
42  %2 = bitcast ptr %coerce.dive to ptr, !dbg !25
43  %3 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %2, i32 0, i32 0, !dbg !25
44  %4 = extractvalue { <2 x float>, <2 x float> } %call, 0, !dbg !25
45  store <2 x float> %4, ptr %3, align 4, !dbg !25
46  %5 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %2, i32 0, i32 1, !dbg !25
47  %6 = extractvalue { <2 x float>, <2 x float> } %call, 1, !dbg !25
48  store <2 x float> %6, ptr %5, align 4, !dbg !25
49  %arrayidx = getelementptr inbounds [3 x %class.c], ptr %a, i64 0, i64 2, !dbg !26
50  %7 = bitcast ptr %arrayidx to ptr, !dbg !27
51  %8 = bitcast ptr %ref.tmp to ptr, !dbg !27
52  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %7, ptr align 4 %8, i64 16, i1 false), !dbg !27, !DIAssignID !32
53  call void @llvm.dbg.assign(metadata i1 undef, metadata !11, metadata !DIExpression(DW_OP_LLVM_fragment, 256, 128), metadata !32, metadata ptr %7, metadata !DIExpression()), !dbg !23
54  %9 = bitcast ptr %ref.tmp to ptr, !dbg !26
55  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4, !dbg !26
56  %10 = bitcast ptr %a to ptr, !dbg !33
57  call void @llvm.lifetime.end.p0(i64 48, ptr %10) #4, !dbg !33
58  ret void, !dbg !33
59}
60
61; Function Attrs: argmemonly nofree nosync nounwind willreturn
62declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
63
64; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
65declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
66
67declare !dbg !34 dso_local { <2 x float>, <2 x float> } @_Z3fn1v() #3
68
69; Function Attrs: argmemonly nofree nosync nounwind willreturn
70declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1
71
72; Function Attrs: argmemonly nofree nosync nounwind willreturn
73declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
74
75; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
76declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #2
77
78!llvm.dbg.cu = !{!0}
79!llvm.module.flags = !{!3, !4, !5, !1000}
80!llvm.ident = !{!6}
81
82!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
83!1 = !DIFile(filename: "reduce.cpp", directory: "/")
84!2 = !{}
85!3 = !{i32 7, !"Dwarf Version", i32 4}
86!4 = !{i32 2, !"Debug Info Version", i32 3}
87!5 = !{i32 1, !"wchar_size", i32 4}
88!6 = !{!"clang version 12.0.0"}
89!7 = distinct !DISubprogram(name: "d", linkageName: "_Z1dv", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
90!8 = !DISubroutineType(types: !9)
91!9 = !{null}
92!10 = !{!11}
93!11 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 6, type: !12)
94!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 384, elements: !20)
95!13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "c", file: !1, line: 1, size: 128, flags: DIFlagTypePassByValue, elements: !14, identifier: "_ZTS1c")
96!14 = !{!15}
97!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 2, baseType: !16, size: 128)
98!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 128, elements: !18)
99!17 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
100!18 = !{!19}
101!19 = !DISubrange(count: 4)
102!20 = !{!21}
103!21 = !DISubrange(count: 3)
104!22 = distinct !DIAssignID()
105!23 = !DILocation(line: 0, scope: !7)
106!24 = !DILocation(line: 6, column: 3, scope: !7)
107!25 = !DILocation(line: 7, column: 10, scope: !7)
108!26 = !DILocation(line: 7, column: 3, scope: !7)
109!27 = !DILocation(line: 7, column: 8, scope: !7)
110!32 = distinct !DIAssignID()
111!33 = !DILocation(line: 8, column: 1, scope: !7)
112!34 = !DISubprogram(name: "fn1", linkageName: "_Z3fn1v", scope: !1, file: !1, line: 4, type: !35, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
113!35 = !DISubroutineType(types: !36)
114!36 = !{!13}
115!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
116