xref: /llvm-project/llvm/test/DebugInfo/X86/sroasplit-4.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -passes='sroa' < %s -S -o - | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators -passes='sroa' < %s -S -o - | FileCheck %s
3;
4; Test that recursively splitting an alloca updates the debug info correctly.
5; CHECK: %[[T:.*]] = load i64, ptr @t, align 8
6; CHECK: #dbg_value(i64 %[[T]], ![[Y:.*]], !DIExpression(DW_OP_LLVM_fragment, 0, 64),
7; CHECK: %[[T1:.*]] = load i64, ptr @t, align 8
8; CHECK: #dbg_value(i64 %[[T1]], ![[Y]], !DIExpression(DW_OP_LLVM_fragment, 64, 64),
9; CHECK: #dbg_value(i64 %[[T]], ![[R:.*]], !DIExpression(DW_OP_LLVM_fragment, 192, 64),
10; CHECK: #dbg_value(i64 %[[T1]], ![[R]], !DIExpression(DW_OP_LLVM_fragment, 256, 64),
11;
12; struct p {
13;   __SIZE_TYPE__ s;
14;   __SIZE_TYPE__ t;
15; };
16;
17; struct r {
18;   int i;
19;   struct p x;
20;   struct p y;
21; };
22;
23; extern int call_me(struct r);
24; extern int maybe();
25; extern __SIZE_TYPE__ t;
26;
27; int test() {
28;   if (maybe())
29;     return 0;
30;   struct p y = {t, t};
31;   struct r r = {.y = y};
32;   return call_me(r);
33; }
34
35; ModuleID = 'pr22393.cc'
36target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
37target triple = "x86_64-apple-darwin"
38
39%struct.p = type { i64, i64 }
40%struct.r = type { i32, %struct.p, %struct.p }
41
42@t = external global i64
43
44; Function Attrs: nounwind
45define i32 @_Z4testv() #0 !dbg !17 {
46entry:
47  %retval = alloca i32, align 4
48  %y = alloca %struct.p, align 8
49  %r = alloca %struct.r, align 8
50  %agg.tmp = alloca %struct.r, align 8
51  %call = call i32 @_Z5maybev(), !dbg !24
52  %tobool = icmp ne i32 %call, 0, !dbg !24
53  br i1 %tobool, label %if.then, label %if.end, !dbg !26
54
55if.then:                                          ; preds = %entry
56  store i32 0, ptr %retval, !dbg !27
57  br label %return, !dbg !27
58
59if.end:                                           ; preds = %entry
60  call void @llvm.dbg.declare(metadata ptr %y, metadata !28, metadata !29), !dbg !30
61  %0 = load i64, ptr @t, align 8, !dbg !30
62  store i64 %0, ptr %y, align 8, !dbg !30
63  %t = getelementptr inbounds %struct.p, ptr %y, i32 0, i32 1, !dbg !30
64  %1 = load i64, ptr @t, align 8, !dbg !30
65  store i64 %1, ptr %t, align 8, !dbg !30
66  call void @llvm.dbg.declare(metadata ptr %r, metadata !31, metadata !29), !dbg !32
67  store i32 0, ptr %r, align 4, !dbg !32
68  %x = getelementptr inbounds %struct.r, ptr %r, i32 0, i32 1, !dbg !32
69  store i64 0, ptr %x, align 8, !dbg !32
70  %t2 = getelementptr inbounds %struct.p, ptr %x, i32 0, i32 1, !dbg !32
71  store i64 0, ptr %t2, align 8, !dbg !32
72  %y3 = getelementptr inbounds %struct.r, ptr %r, i32 0, i32 2, !dbg !32
73  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %y3, ptr align 8 %y, i64 16, i1 false), !dbg !32
74  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %agg.tmp, ptr align 8 %r, i64 40, i1 false), !dbg !33
75  %call4 = call i32 @_Z7call_me1r(ptr byval(%struct.r) align 8 %agg.tmp), !dbg !33
76  store i32 %call4, ptr %retval, !dbg !33
77  br label %return, !dbg !33
78
79return:                                           ; preds = %if.end, %if.then
80  %2 = load i32, ptr %retval, !dbg !34
81  ret i32 %2, !dbg !34
82}
83
84declare i32 @_Z5maybev()
85
86; Function Attrs: nounwind readnone
87declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
88
89; Function Attrs: nounwind
90declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1) #3
91
92declare i32 @_Z7call_me1r(ptr byval(%struct.r) align 8)
93
94attributes #0 = { nounwind }
95attributes #2 = { nounwind readnone }
96attributes #3 = { nounwind }
97
98!llvm.dbg.cu = !{!0}
99!llvm.module.flags = !{!21, !22}
100!llvm.ident = !{!23}
101
102!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
103!1 = !DIFile(filename: "<stdin>", directory: "")
104!2 = !{}
105!3 = !{!4, !10}
106!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "p", line: 3, size: 128, align: 64, file: !5, elements: !6, identifier: "_ZTS1p")
107!5 = !DIFile(filename: "pr22393.cc", directory: "")
108!6 = !{!7, !9}
109!7 = !DIDerivedType(tag: DW_TAG_member, name: "s", line: 4, size: 64, align: 64, file: !5, scope: !4, baseType: !8)
110!8 = !DIBasicType(tag: DW_TAG_base_type, name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned)
111!9 = !DIDerivedType(tag: DW_TAG_member, name: "t", line: 5, size: 64, align: 64, offset: 64, file: !5, scope: !4, baseType: !8)
112!10 = !DICompositeType(tag: DW_TAG_structure_type, name: "r", line: 8, size: 320, align: 64, file: !5, elements: !11, identifier: "_ZTS1r")
113!11 = !{!12, !14, !15}
114!12 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 9, size: 32, align: 32, file: !5, scope: !10, baseType: !13)
115!13 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
116!14 = !DIDerivedType(tag: DW_TAG_member, name: "x", line: 10, size: 128, align: 64, offset: 64, file: !5, scope: !10, baseType: !4)
117!15 = !DIDerivedType(tag: DW_TAG_member, name: "y", line: 11, size: 128, align: 64, offset: 192, file: !5, scope: !10, baseType: !4)
118!17 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", line: 18, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 18, file: !5, scope: !18, type: !19, retainedNodes: !2)
119!18 = !DIFile(filename: "pr22393.cc", directory: "")
120!19 = !DISubroutineType(types: !20)
121!20 = !{!13}
122!21 = !{i32 2, !"Dwarf Version", i32 4}
123!22 = !{i32 2, !"Debug Info Version", i32 3}
124!23 = !{!"clang version 3.7.0 "}
125!24 = !DILocation(line: 19, scope: !25)
126!25 = distinct !DILexicalBlock(line: 19, column: 0, file: !5, scope: !17)
127!26 = !DILocation(line: 19, scope: !17)
128!27 = !DILocation(line: 20, scope: !25)
129!28 = !DILocalVariable(name: "y", line: 21, scope: !17, file: !18, type: !4)
130!29 = !DIExpression()
131!30 = !DILocation(line: 21, scope: !17)
132!31 = !DILocalVariable(name: "r", line: 22, scope: !17, file: !18, type: !10)
133!32 = !DILocation(line: 22, scope: !17)
134!33 = !DILocation(line: 23, scope: !17)
135!34 = !DILocation(line: 24, scope: !17)
136