blob: d789c79b7c56c790ea52470d171f1495d5d5f3b8 [file] [log] [blame]
Hal Finkel9caa8f72013-07-16 17:10:55 +00001; RUN: opt < %s -inline -S | FileCheck %s
2
3target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
4target triple = "powerpc64-unknown-linux-gnu"
5
6%struct.s = type { i32, i32 }
7
8define void @foo(%struct.s* byval nocapture readonly %a) {
9entry:
10 %x = alloca [2 x i32], align 4
11 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
12 %0 = load i32* %a1, align 4, !tbaa !0
13 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
14 store i32 %0, i32* %arrayidx, align 4, !tbaa !0
15 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
16 %1 = load i32* %b, align 4, !tbaa !0
17 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
18 store i32 %1, i32* %arrayidx2, align 4, !tbaa !0
19 call void @bar(i32* %arrayidx) #2
20 ret void
21}
22
23define void @foo0(%struct.s* byval nocapture readonly %a) {
24entry:
25 %x = alloca [2 x i32]
26 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
27 %0 = load i32* %a1, align 4, !tbaa !0
28 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
29 store i32 %0, i32* %arrayidx, align 4, !tbaa !0
30 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
31 %1 = load i32* %b, align 4, !tbaa !0
32 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
33 store i32 %1, i32* %arrayidx2, align 4, !tbaa !0
34 call void @bar(i32* %arrayidx) #2
35 ret void
36}
37
Hal Finkelec7cd262013-07-17 14:32:41 +000038define void @foo1(%struct.s* byval nocapture readonly %a) {
39entry:
40 %x = alloca [2 x i32], align 1
41 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
42 %0 = load i32* %a1, align 4, !tbaa !0
43 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
44 store i32 %0, i32* %arrayidx, align 4, !tbaa !0
45 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
46 %1 = load i32* %b, align 4, !tbaa !0
47 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
48 store i32 %1, i32* %arrayidx2, align 4, !tbaa !0
49 call void @bar(i32* %arrayidx) #2
50 ret void
51}
52
Hal Finkel9caa8f72013-07-16 17:10:55 +000053declare void @bar(i32*) #1
54
55define void @goo(%struct.s* byval nocapture readonly %a) {
56entry:
57 %x = alloca [2 x i32], align 32
58 %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0
59 %0 = load i32* %a1, align 4, !tbaa !0
60 %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0
61 store i32 %0, i32* %arrayidx, align 32, !tbaa !0
62 %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1
63 %1 = load i32* %b, align 4, !tbaa !0
64 %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1
65 store i32 %1, i32* %arrayidx2, align 4, !tbaa !0
66 call void @bar(i32* %arrayidx) #2
67 ret void
68}
69
70; CHECK-LABEL: @main
71; CHECK: alloca [2 x i32], align 32
72; CHECK-NOT: alloca [2 x i32]
73; CHECK: ret i32 0
74
75define signext i32 @main() {
76entry:
77 %a = alloca i64, align 8
78 %tmpcast = bitcast i64* %a to %struct.s*
79 store i64 0, i64* %a, align 8
80 %a1 = bitcast i64* %a to i32*
81 store i32 1, i32* %a1, align 8, !tbaa !0
82 call void @foo(%struct.s* byval %tmpcast)
83 store i32 2, i32* %a1, align 8, !tbaa !0
84 call void @goo(%struct.s* byval %tmpcast)
85 ret i32 0
86}
87
88; CHECK-LABEL: @test0
89; CHECK: alloca [2 x i32], align 32
90; CHECK-NOT: alloca [2 x i32]
91; CHECK: ret i32 0
92
93define signext i32 @test0() {
94entry:
95 %a = alloca i64, align 8
96 %tmpcast = bitcast i64* %a to %struct.s*
97 store i64 0, i64* %a, align 8
98 %a1 = bitcast i64* %a to i32*
99 store i32 1, i32* %a1, align 8, !tbaa !0
100 call void @foo0(%struct.s* byval %tmpcast)
101 store i32 2, i32* %a1, align 8, !tbaa !0
102 call void @goo(%struct.s* byval %tmpcast)
103 ret i32 0
104}
105
Hal Finkelec7cd262013-07-17 14:32:41 +0000106; CHECK-LABEL: @test1
107; CHECK: {{alloca \[2 x i32\]$}}
108; CHECK-NOT: alloca [2 x i32]
109; CHECK: ret i32 0
110
111define signext i32 @test1() {
112entry:
113 %a = alloca i64, align 8
114 %tmpcast = bitcast i64* %a to %struct.s*
115 store i64 0, i64* %a, align 8
116 %a1 = bitcast i64* %a to i32*
117 store i32 1, i32* %a1, align 8, !tbaa !0
118 call void @foo0(%struct.s* byval %tmpcast)
119 store i32 2, i32* %a1, align 8, !tbaa !0
120 call void @foo1(%struct.s* byval %tmpcast)
121 ret i32 0
122}
123
Hal Finkel9caa8f72013-07-16 17:10:55 +0000124!0 = metadata !{metadata !"int", metadata !1}
125!1 = metadata !{metadata !"omnipotent char", metadata !2}
126!2 = metadata !{metadata !"Simple C/C++ TBAA"}
127