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