Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame^] | 1 | ; RUN: opt < %s -inline -S | FileCheck %s |
| 2 | |
| 3 | target 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" |
| 4 | target triple = "powerpc64-unknown-linux-gnu" |
| 5 | |
| 6 | %struct.s = type { i32, i32 } |
| 7 | |
| 8 | define void @foo(%struct.s* byval nocapture readonly %a) { |
| 9 | entry: |
| 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 | |
| 23 | define void @foo0(%struct.s* byval nocapture readonly %a) { |
| 24 | entry: |
| 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 | |
| 38 | declare void @bar(i32*) #1 |
| 39 | |
| 40 | define void @goo(%struct.s* byval nocapture readonly %a) { |
| 41 | entry: |
| 42 | %x = alloca [2 x i32], align 32 |
| 43 | %a1 = getelementptr inbounds %struct.s* %a, i64 0, i32 0 |
| 44 | %0 = load i32* %a1, align 4, !tbaa !0 |
| 45 | %arrayidx = getelementptr inbounds [2 x i32]* %x, i64 0, i64 0 |
| 46 | store i32 %0, i32* %arrayidx, align 32, !tbaa !0 |
| 47 | %b = getelementptr inbounds %struct.s* %a, i64 0, i32 1 |
| 48 | %1 = load i32* %b, align 4, !tbaa !0 |
| 49 | %arrayidx2 = getelementptr inbounds [2 x i32]* %x, i64 0, i64 1 |
| 50 | store i32 %1, i32* %arrayidx2, align 4, !tbaa !0 |
| 51 | call void @bar(i32* %arrayidx) #2 |
| 52 | ret void |
| 53 | } |
| 54 | |
| 55 | ; CHECK-LABEL: @main |
| 56 | ; CHECK: alloca [2 x i32], align 32 |
| 57 | ; CHECK-NOT: alloca [2 x i32] |
| 58 | ; CHECK: ret i32 0 |
| 59 | |
| 60 | define signext i32 @main() { |
| 61 | entry: |
| 62 | %a = alloca i64, align 8 |
| 63 | %tmpcast = bitcast i64* %a to %struct.s* |
| 64 | store i64 0, i64* %a, align 8 |
| 65 | %a1 = bitcast i64* %a to i32* |
| 66 | store i32 1, i32* %a1, align 8, !tbaa !0 |
| 67 | call void @foo(%struct.s* byval %tmpcast) |
| 68 | store i32 2, i32* %a1, align 8, !tbaa !0 |
| 69 | call void @goo(%struct.s* byval %tmpcast) |
| 70 | ret i32 0 |
| 71 | } |
| 72 | |
| 73 | ; CHECK-LABEL: @test0 |
| 74 | ; CHECK: alloca [2 x i32], align 32 |
| 75 | ; CHECK-NOT: alloca [2 x i32] |
| 76 | ; CHECK: ret i32 0 |
| 77 | |
| 78 | define signext i32 @test0() { |
| 79 | entry: |
| 80 | %a = alloca i64, align 8 |
| 81 | %tmpcast = bitcast i64* %a to %struct.s* |
| 82 | store i64 0, i64* %a, align 8 |
| 83 | %a1 = bitcast i64* %a to i32* |
| 84 | store i32 1, i32* %a1, align 8, !tbaa !0 |
| 85 | call void @foo0(%struct.s* byval %tmpcast) |
| 86 | store i32 2, i32* %a1, align 8, !tbaa !0 |
| 87 | call void @goo(%struct.s* byval %tmpcast) |
| 88 | ret i32 0 |
| 89 | } |
| 90 | |
| 91 | !0 = metadata !{metadata !"int", metadata !1} |
| 92 | !1 = metadata !{metadata !"omnipotent char", metadata !2} |
| 93 | !2 = metadata !{metadata !"Simple C/C++ TBAA"} |
| 94 | |