; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn,instcombine -S | FileCheck %s
define i32 @test() {
-; CHECK: %Y.DONOTREMOVE = load i32, i32* %A
+; CHECK: %Y.DONOTREMOVE = load i32, ptr %A
; CHECK: %Z = sub i32 0, %Y.DONOTREMOVE
%A = alloca i32
- store i32 0, i32* %A
- %X = load i32, i32* %A
- %B = bitcast i32* %A to i8*
- %C = getelementptr i8, i8* %B, i64 1
- store i8 1, i8* %C ; Aliases %A
- %Y.DONOTREMOVE = load i32, i32* %A
+ store i32 0, ptr %A
+ %X = load i32, ptr %A
+ %C = getelementptr i8, ptr %A, i64 1
+ store i8 1, ptr %C ; Aliases %A
+ %Y.DONOTREMOVE = load i32, ptr %A
%Z = sub i32 %X, %Y.DONOTREMOVE
ret i32 %Z
}
; RUN: opt < %s -aa-pipeline=basic-aa -passes=dse -S | FileCheck %s
-define void @test({i32,i32 }* %P) {
-; CHECK: store i32 0, i32* %X
- %Q = getelementptr {i32,i32}, {i32,i32}* %P, i32 1
- %X = getelementptr {i32,i32}, {i32,i32}* %Q, i32 0, i32 1
- %Y = getelementptr {i32,i32}, {i32,i32}* %Q, i32 1, i32 1
- store i32 0, i32* %X
- store i32 1, i32* %Y
+define void @test(ptr %P) {
+; CHECK: store i32 0, ptr %X
+ %Q = getelementptr {i32,i32}, ptr %P, i32 1
+ %X = getelementptr {i32,i32}, ptr %Q, i32 0, i32 1
+ %Y = getelementptr {i32,i32}, ptr %Q, i32 1, i32 1
+ store i32 0, ptr %X
+ store i32 1, ptr %Y
ret void
}
target triple = "i386-apple-darwin8"
%struct.x = type { [4 x i32] }
-define void @foo(%struct.x* byval(%struct.x) align 4 %X) nounwind {
-; CHECK: store i32 2, i32* %tmp1
+define void @foo(ptr byval(%struct.x) align 4 %X) nounwind {
+; CHECK: store i32 2, ptr %tmp1
entry:
- %tmp = getelementptr %struct.x, %struct.x* %X, i32 0, i32 0 ; <[4 x i32]*> [#uses=1]
- %tmp1 = getelementptr [4 x i32], [4 x i32]* %tmp, i32 0, i32 3 ; <i32*> [#uses=1]
- store i32 2, i32* %tmp1, align 4
- %tmp2 = call i32 (...) @bar(%struct.x* byval(%struct.x) align 4 %X ) nounwind ; <i32> [#uses=0]
+ %tmp = getelementptr %struct.x, ptr %X, i32 0, i32 0 ; <ptr> [#uses=1]
+ %tmp1 = getelementptr [4 x i32], ptr %tmp, i32 0, i32 3 ; <ptr> [#uses=1]
+ store i32 2, ptr %tmp1, align 4
+ %tmp2 = call i32 (...) @bar(ptr byval(%struct.x) align 4 %X ) nounwind ; <i32> [#uses=0]
br label %return
return: ; preds = %entry
ret void
; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn -S | FileCheck %s
-declare noalias i32* @noalias()
+declare noalias ptr @noalias()
define i32 @test(i32 %x) {
-; CHECK: load i32, i32* %a
- %a = call i32* @noalias()
- store i32 1, i32* %a
- %b = getelementptr i32, i32* %a, i32 %x
- store i32 2, i32* %b
+; CHECK: load i32, ptr %a
+ %a = call ptr @noalias()
+ store i32 1, ptr %a
+ %b = getelementptr i32, ptr %a, i32 %x
+ store i32 2, ptr %b
- %c = load i32, i32* %a
+ %c = load i32, ptr %a
ret i32 %c
}
@B = global i32 8
; CHECK: define i32 @test()
-; CHECK-NEXT: store i32 123, i32* @B
+; CHECK-NEXT: store i32 123, ptr @B
; CHECK-NEXT: ret i32 0
define i32 @test() {
- %A1 = load i32, i32* @A
+ %A1 = load i32, ptr @A
- store i32 123, i32* @B ; Store cannot alias @A
+ store i32 123, ptr @B ; Store cannot alias @A
- %A2 = load i32, i32* @A
+ %A2 = load i32, ptr @A
%X = sub i32 %A1, %A2
ret i32 %X
}
; CHECK: define i32 @test2()
; CHECK-NEXT: br label %Loop
; CHECK: Loop:
-; CHECK-NEXT: store i32 0, i32* @B
+; CHECK-NEXT: store i32 0, ptr @B
; CHECK-NEXT: br i1 true, label %out, label %Loop
; CHECK: out:
; CHECK-NEXT: ret i32 0
define i32 @test2() {
- %A1 = load i32, i32* @A
+ %A1 = load i32, ptr @A
br label %Loop
Loop:
%AP = phi i32 [0, %0], [%X, %Loop]
- store i32 %AP, i32* @B ; Store cannot alias @A
+ store i32 %AP, ptr @B ; Store cannot alias @A
- %A2 = load i32, i32* @A
+ %A2 = load i32, ptr @A
%X = sub i32 %A1, %A2
%c = icmp eq i32 %X, 0
br i1 %c, label %out, label %Loop
define i32 @test3() {
%X = alloca i32
- store i32 7, i32* %X
+ store i32 7, ptr %X
call void @external()
- %V = load i32, i32* %X
+ %V = load i32, ptr %X
ret i32 %V
}
target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
; Make sure that basicaa thinks R and r are must aliases.
-define i32 @test1(i8 * %P) {
+define i32 @test1(ptr %P) {
entry:
- %Q = bitcast i8* %P to {i32, i32}*
- %R = getelementptr {i32, i32}, {i32, i32}* %Q, i32 0, i32 1
- %S = load i32, i32* %R
+ %R = getelementptr {i32, i32}, ptr %P, i32 0, i32 1
+ %S = load i32, ptr %R
- %q = bitcast i8* %P to {i32, i32}*
- %r = getelementptr {i32, i32}, {i32, i32}* %q, i32 0, i32 1
- %s = load i32, i32* %r
+ %r = getelementptr {i32, i32}, ptr %P, i32 0, i32 1
+ %s = load i32, ptr %r
%t = sub i32 %S, %s
ret i32 %t
; CHECK: ret i32 0
}
-define i32 @test2(i8 * %P) {
+define i32 @test2(ptr %P) {
entry:
- %Q = bitcast i8* %P to {i32, i32, i32}*
- %R = getelementptr {i32, i32, i32}, {i32, i32, i32}* %Q, i32 0, i32 1
- %S = load i32, i32* %R
+ %R = getelementptr {i32, i32, i32}, ptr %P, i32 0, i32 1
+ %S = load i32, ptr %R
- %r = getelementptr {i32, i32, i32}, {i32, i32, i32}* %Q, i32 0, i32 2
- store i32 42, i32* %r
+ %r = getelementptr {i32, i32, i32}, ptr %P, i32 0, i32 2
+ store i32 42, ptr %r
- %s = load i32, i32* %R
+ %s = load i32, ptr %R
%t = sub i32 %S, %s
ret i32 %t
; This was a miscompilation.
-define i32 @test3({float, {i32, i32, i32}}* %P) {
+define i32 @test3(ptr %P) {
entry:
- %P2 = getelementptr {float, {i32, i32, i32}}, {float, {i32, i32, i32}}* %P, i32 0, i32 1
- %R = getelementptr {i32, i32, i32}, {i32, i32, i32}* %P2, i32 0, i32 1
- %S = load i32, i32* %R
+ %P2 = getelementptr {float, {i32, i32, i32}}, ptr %P, i32 0, i32 1
+ %R = getelementptr {i32, i32, i32}, ptr %P2, i32 0, i32 1
+ %S = load i32, ptr %R
- %r = getelementptr {i32, i32, i32}, {i32, i32, i32}* %P2, i32 0, i32 2
- store i32 42, i32* %r
+ %r = getelementptr {i32, i32, i32}, ptr %P2, i32 0, i32 2
+ store i32 42, ptr %r
- %s = load i32, i32* %R
+ %s = load i32, ptr %R
%t = sub i32 %S, %s
ret i32 %t
;; This is reduced from the SmallPtrSet constructor.
-%SmallPtrSetImpl = type { i8**, i32, i32, i32, [1 x i8*] }
-%SmallPtrSet64 = type { %SmallPtrSetImpl, [64 x i8*] }
+%SmallPtrSetImpl = type { ptr, i32, i32, i32, [1 x ptr] }
+%SmallPtrSet64 = type { %SmallPtrSetImpl, [64 x ptr] }
-define i32 @test4(%SmallPtrSet64* %P) {
+define i32 @test4(ptr %P) {
entry:
- %tmp2 = getelementptr inbounds %SmallPtrSet64, %SmallPtrSet64* %P, i64 0, i32 0, i32 1
- store i32 64, i32* %tmp2, align 8
- %tmp3 = getelementptr inbounds %SmallPtrSet64, %SmallPtrSet64* %P, i64 0, i32 0, i32 4, i64 64
- store i8* null, i8** %tmp3, align 8
- %tmp4 = load i32, i32* %tmp2, align 8
+ %tmp2 = getelementptr inbounds %SmallPtrSet64, ptr %P, i64 0, i32 0, i32 1
+ store i32 64, ptr %tmp2, align 8
+ %tmp3 = getelementptr inbounds %SmallPtrSet64, ptr %P, i64 0, i32 0, i32 4, i64 64
+ store ptr null, ptr %tmp3, align 8
+ %tmp4 = load i32, ptr %tmp2, align 8
ret i32 %tmp4
; CHECK-LABEL: @test4(
; CHECK: ret i32 64
}
; P[i] != p[i+1]
-define i32 @test5(i32* %p, i64 %i) {
- %pi = getelementptr i32, i32* %p, i64 %i
+define i32 @test5(ptr %p, i64 %i) {
+ %pi = getelementptr i32, ptr %p, i64 %i
%i.next = add i64 %i, 1
- %pi.next = getelementptr i32, i32* %p, i64 %i.next
- %x = load i32, i32* %pi
- store i32 42, i32* %pi.next
- %y = load i32, i32* %pi
+ %pi.next = getelementptr i32, ptr %p, i64 %i.next
+ %x = load i32, ptr %pi
+ store i32 42, ptr %pi.next
+ %y = load i32, ptr %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test5(
; CHECK: ret i32 0
}
-define i32 @test5_as1_smaller_size(i32 addrspace(1)* %p, i8 %i) {
- %pi = getelementptr i32, i32 addrspace(1)* %p, i8 %i
+define i32 @test5_as1_smaller_size(ptr addrspace(1) %p, i8 %i) {
+ %pi = getelementptr i32, ptr addrspace(1) %p, i8 %i
%i.next = add i8 %i, 1
- %pi.next = getelementptr i32, i32 addrspace(1)* %p, i8 %i.next
- %x = load i32, i32 addrspace(1)* %pi
- store i32 42, i32 addrspace(1)* %pi.next
- %y = load i32, i32 addrspace(1)* %pi
+ %pi.next = getelementptr i32, ptr addrspace(1) %p, i8 %i.next
+ %x = load i32, ptr addrspace(1) %pi
+ store i32 42, ptr addrspace(1) %pi.next
+ %y = load i32, ptr addrspace(1) %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test5_as1_smaller_size(
; CHECK: ret i32 0
}
-define i32 @test5_as1_same_size(i32 addrspace(1)* %p, i16 %i) {
- %pi = getelementptr i32, i32 addrspace(1)* %p, i16 %i
+define i32 @test5_as1_same_size(ptr addrspace(1) %p, i16 %i) {
+ %pi = getelementptr i32, ptr addrspace(1) %p, i16 %i
%i.next = add i16 %i, 1
- %pi.next = getelementptr i32, i32 addrspace(1)* %p, i16 %i.next
- %x = load i32, i32 addrspace(1)* %pi
- store i32 42, i32 addrspace(1)* %pi.next
- %y = load i32, i32 addrspace(1)* %pi
+ %pi.next = getelementptr i32, ptr addrspace(1) %p, i16 %i.next
+ %x = load i32, ptr addrspace(1) %pi
+ store i32 42, ptr addrspace(1) %pi.next
+ %y = load i32, ptr addrspace(1) %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test5_as1_same_size(
}
; P[i] != p[(i*4)|1]
-define i32 @test6(i32* %p, i64 %i1) {
+define i32 @test6(ptr %p, i64 %i1) {
%i = shl i64 %i1, 2
- %pi = getelementptr i32, i32* %p, i64 %i
+ %pi = getelementptr i32, ptr %p, i64 %i
%i.next = or i64 %i, 1
- %pi.next = getelementptr i32, i32* %p, i64 %i.next
- %x = load i32, i32* %pi
- store i32 42, i32* %pi.next
- %y = load i32, i32* %pi
+ %pi.next = getelementptr i32, ptr %p, i64 %i.next
+ %x = load i32, ptr %pi
+ store i32 42, ptr %pi.next
+ %y = load i32, ptr %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test6(
}
; P[1] != P[i*4]
-define i32 @test7(i32* %p, i64 %i) {
- %pi = getelementptr i32, i32* %p, i64 1
+define i32 @test7(ptr %p, i64 %i) {
+ %pi = getelementptr i32, ptr %p, i64 1
%i.next = shl i64 %i, 2
- %pi.next = getelementptr i32, i32* %p, i64 %i.next
- %x = load i32, i32* %pi
- store i32 42, i32* %pi.next
- %y = load i32, i32* %pi
+ %pi.next = getelementptr i32, ptr %p, i64 %i.next
+ %x = load i32, ptr %pi
+ store i32 42, ptr %pi.next
+ %y = load i32, ptr %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test7(
; P[zext(i)] != p[zext(i+1)]
; PR1143
-define i32 @test8(i32* %p, i16 %i) {
+define i32 @test8(ptr %p, i16 %i) {
%i1 = zext i16 %i to i32
- %pi = getelementptr i32, i32* %p, i32 %i1
+ %pi = getelementptr i32, ptr %p, i32 %i1
%i.next = add i16 %i, 1
%i.next2 = zext i16 %i.next to i32
- %pi.next = getelementptr i32, i32* %p, i32 %i.next2
- %x = load i32, i32* %pi
- store i32 42, i32* %pi.next
- %y = load i32, i32* %pi
+ %pi.next = getelementptr i32, ptr %p, i32 %i.next2
+ %x = load i32, ptr %pi
+ store i32 42, ptr %pi.next
+ %y = load i32, ptr %pi
%z = sub i32 %x, %y
ret i32 %z
; CHECK-LABEL: @test8(
; CHECK: ret i32 0
}
-define i8 @test9([4 x i8] *%P, i32 %i, i32 %j) {
+define i8 @test9(ptr %P, i32 %i, i32 %j) {
%i2 = shl i32 %i, 2
%i3 = add i32 %i2, 1
; P2 = P + 1 + 4*i
- %P2 = getelementptr [4 x i8], [4 x i8] *%P, i32 0, i32 %i3
+ %P2 = getelementptr [4 x i8], ptr %P, i32 0, i32 %i3
%j2 = shl i32 %j, 2
; P4 = P + 4*j
- %P4 = getelementptr [4 x i8], [4 x i8]* %P, i32 0, i32 %j2
+ %P4 = getelementptr [4 x i8], ptr %P, i32 0, i32 %j2
- %x = load i8, i8* %P2
- store i8 42, i8* %P4
- %y = load i8, i8* %P2
+ %x = load i8, ptr %P2
+ store i8 42, ptr %P4
+ %y = load i8, ptr %P2
%z = sub i8 %x, %y
ret i8 %z
; CHECK-LABEL: @test9(
; CHECK: ret i8 0
}
-define i8 @test10([4 x i8] *%P, i32 %i) {
+define i8 @test10(ptr %P, i32 %i) {
%i2 = shl i32 %i, 2
%i3 = add i32 %i2, 4
; P2 = P + 4 + 4*i
- %P2 = getelementptr [4 x i8], [4 x i8] *%P, i32 0, i32 %i3
+ %P2 = getelementptr [4 x i8], ptr %P, i32 0, i32 %i3
; P4 = P + 4*i
- %P4 = getelementptr [4 x i8], [4 x i8]* %P, i32 0, i32 %i2
+ %P4 = getelementptr [4 x i8], ptr %P, i32 0, i32 %i2
- %x = load i8, i8* %P2
- store i8 42, i8* %P4
- %y = load i8, i8* %P2
+ %x = load i8, ptr %P2
+ store i8 42, ptr %P4
+ %y = load i8, ptr %P2
%z = sub i8 %x, %y
ret i8 %z
; CHECK-LABEL: @test10(
}
; (This was a miscompilation.)
-define float @test11(i32 %indvar, [4 x [2 x float]]* %q) nounwind ssp {
+define float @test11(i32 %indvar, ptr %q) nounwind ssp {
%tmp = mul i32 %indvar, -1
%dec = add i32 %tmp, 3
- %scevgep = getelementptr [4 x [2 x float]], [4 x [2 x float]]* %q, i32 0, i32 %dec
- %scevgep35 = bitcast [2 x float]* %scevgep to i64*
- %arrayidx28 = getelementptr inbounds [4 x [2 x float]], [4 x [2 x float]]* %q, i32 0, i32 0
- %y29 = getelementptr inbounds [2 x float], [2 x float]* %arrayidx28, i32 0, i32 1
- store float 1.0, float* %y29, align 4
- store i64 0, i64* %scevgep35, align 4
- %tmp30 = load float, float* %y29, align 4
+ %scevgep = getelementptr [4 x [2 x float]], ptr %q, i32 0, i32 %dec
+ %y29 = getelementptr inbounds [2 x float], ptr %q, i32 0, i32 1
+ store float 1.0, ptr %y29, align 4
+ store i64 0, ptr %scevgep, align 4
+ %tmp30 = load float, ptr %y29, align 4
ret float %tmp30
; CHECK-LABEL: @test11(
; CHECK: ret float %tmp30
}
; (This was a miscompilation.)
-define i32 @test12(i32 %x, i32 %y, i8* %p) nounwind {
- %a = bitcast i8* %p to [13 x i8]*
- %b = getelementptr [13 x i8], [13 x i8]* %a, i32 %x
- %c = bitcast [13 x i8]* %b to [15 x i8]*
- %d = getelementptr [15 x i8], [15 x i8]* %c, i32 %y, i32 8
- %castd = bitcast i8* %d to i32*
- %castp = bitcast i8* %p to i32*
- store i32 1, i32* %castp
- store i32 0, i32* %castd
- %r = load i32, i32* %castp
+define i32 @test12(i32 %x, i32 %y, ptr %p) nounwind {
+ %b = getelementptr [13 x i8], ptr %p, i32 %x
+ %d = getelementptr [15 x i8], ptr %b, i32 %y, i32 8
+ store i32 1, ptr %p
+ store i32 0, ptr %d
+ %r = load i32, ptr %p
ret i32 %r
; CHECK-LABEL: @test12(
; CHECK: ret i32 %r
; CHECK: store i8 42,
; CHECK: store i8 99,
; Find the loads and make sure they are used in the arguments to the printf.
-; CHECK: [[T0ADDR:%[a-zA-Z0-9_]+]] = getelementptr inbounds [3 x i8], [3 x i8]* %t, i32 0, i32 0
-; CHECK: [[T0:%[a-zA-Z0-9_]+]] = load i8, i8* [[T0ADDR]], align 1
+; CHECK: [[T0:%[a-zA-Z0-9_]+]] = load i8, ptr %t, align 1
; CHECK: [[T0ARG:%[a-zA-Z0-9_]+]] = zext i8 [[T0]] to i32
-; CHECK: [[U0ADDR:%[a-zA-Z0-9_]+]] = getelementptr inbounds [3 x i8], [3 x i8]* %u, i32 0, i32 0
-; CHECK: [[U0:%[a-zA-Z0-9_]+]] = load i8, i8* [[U0ADDR]], align 1
+; CHECK: [[U0:%[a-zA-Z0-9_]+]] = load i8, ptr %u, align 1
; CHECK: [[U0ARG:%[a-zA-Z0-9_]+]] = zext i8 [[U0]] to i32
-; CHECK: call i32 (i8*, ...) @printf(i8* noundef nonnull dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i32 [[T0ARG]], i32 [[U0ARG]])
+; CHECK: call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 [[T0ARG]], i32 [[U0ARG]])
; CHECK: ret
define void @test13() {
entry:
%t = alloca [3 x i8], align 1
%u = alloca [3 x i8], align 1
- %tmp = load i32, i32* @P, align 4
+ %tmp = load i32, ptr @P, align 4
%tmp1 = mul i32 %tmp, 3
%mul = add i32 %tmp1, -2147483646
%idxprom = zext i32 %mul to i64
- %arrayidx = getelementptr inbounds [3 x i8], [3 x i8]* %t, i64 0, i64 %idxprom
- store i8 42, i8* %arrayidx, align 1
- %tmp2 = load i32, i32* @Q, align 4
+ %arrayidx = getelementptr inbounds [3 x i8], ptr %t, i64 0, i64 %idxprom
+ store i8 42, ptr %arrayidx, align 1
+ %tmp2 = load i32, ptr @Q, align 4
%tmp3 = mul i32 %tmp2, 3
%mul2 = add i32 %tmp3, 2147483647
%idxprom3 = zext i32 %mul2 to i64
- %arrayidx4 = getelementptr inbounds [3 x i8], [3 x i8]* %u, i64 0, i64 %idxprom3
- store i8 99, i8* %arrayidx4, align 1
- %arrayidx5 = getelementptr inbounds [3 x i8], [3 x i8]* %t, i64 0, i64 0
- %tmp4 = load i8, i8* %arrayidx5, align 1
+ %arrayidx4 = getelementptr inbounds [3 x i8], ptr %u, i64 0, i64 %idxprom3
+ store i8 99, ptr %arrayidx4, align 1
+ %tmp4 = load i8, ptr %t, align 1
%conv = zext i8 %tmp4 to i32
- %arrayidx6 = getelementptr inbounds [3 x i8], [3 x i8]* %u, i64 0, i64 0
- %tmp5 = load i8, i8* %arrayidx6, align 1
+ %tmp5 = load i8, ptr %u, align 1
%conv7 = zext i8 %tmp5 to i32
- %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %conv, i32 %conv7)
+ %call = call i32 (ptr, ...) @printf(ptr @.str, i32 %conv, i32 %conv7)
ret void
}
-declare i32 @printf(i8*, ...)
+declare i32 @printf(ptr, ...)
ret void
}
-; CHECK: NoModRef: call void @llvm.memset.p0i8.i64(i8* @A, i8 0, i64 1, i1 false) <-> call void @llvm.memset.p0i8.i64(i8* @B, i8 0, i64 1, i1 false)
-; CHECK: NoModRef: call void @llvm.memset.p0i8.i64(i8* @B, i8 0, i64 1, i1 false) <-> call void @llvm.memset.p0i8.i64(i8* @A, i8 0, i64 1, i1 false)
+; CHECK: NoModRef: call void @llvm.memset.p0.i64(ptr @A, i8 0, i64 1, i1 false) <-> call void @llvm.memset.p0.i64(ptr @B, i8 0, i64 1, i1 false)
+; CHECK: NoModRef: call void @llvm.memset.p0.i64(ptr @B, i8 0, i64 1, i1 false) <-> call void @llvm.memset.p0.i64(ptr @A, i8 0, i64 1, i1 false)
-declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i1) nounwind
+declare void @llvm.memset.p0.i64(ptr nocapture, i8, i64, i1) nounwind
@A = external global i8
@B = external global i8
define void @test1() {
- call void @llvm.memset.p0i8.i64(i8* @A, i8 0, i64 1, i1 false)
- call void @llvm.memset.p0i8.i64(i8* @B, i8 0, i64 1, i1 false)
+ call void @llvm.memset.p0.i64(ptr @A, i8 0, i64 1, i1 false)
+ call void @llvm.memset.p0.i64(ptr @B, i8 0, i64 1, i1 false)
ret void
}
; specifically special cased exactly these two intrinsics in
; MemoryLocation::getForArgument.
-; CHECK: define <8 x i16> @test1(i8* %p, <8 x i16> %y) {
+; CHECK: define <8 x i16> @test1(ptr %p, <8 x i16> %y) {
; CHECK-NEXT: entry:
-; CHECK-NEXT: %q = getelementptr i8, i8* %p, i64 16
-; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p, i32 16) [[ATTR:#[0-9]+]]
-; CHECK-NEXT: call void @llvm.arm.neon.vst1.p0i8.v8i16(i8* %q, <8 x i16> %y, i32 16)
+; CHECK-NEXT: %q = getelementptr i8, ptr %p, i64 16
+; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0(ptr %p, i32 16) [[ATTR:#[0-9]+]]
+; CHECK-NEXT: call void @llvm.arm.neon.vst1.p0.v8i16(ptr %q, <8 x i16> %y, i32 16)
; CHECK-NEXT: %c = add <8 x i16> %a, %a
-define <8 x i16> @test1(i8* %p, <8 x i16> %y) {
+define <8 x i16> @test1(ptr %p, <8 x i16> %y) {
entry:
- %q = getelementptr i8, i8* %p, i64 16
- %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p, i32 16) nounwind
- call void @llvm.arm.neon.vst1.p0i8.v8i16(i8* %q, <8 x i16> %y, i32 16)
- %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8* %p, i32 16) nounwind
+ %q = getelementptr i8, ptr %p, i64 16
+ %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0(ptr %p, i32 16) nounwind
+ call void @llvm.arm.neon.vst1.p0.v8i16(ptr %q, <8 x i16> %y, i32 16)
+ %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16.p0(ptr %p, i32 16) nounwind
%c = add <8 x i16> %a, %b
ret <8 x i16> %c
}
-declare <8 x i16> @llvm.arm.neon.vld1.v8i16.p0i8(i8*, i32) nounwind readonly
-declare void @llvm.arm.neon.vst1.p0i8.v8i16(i8*, <8 x i16>, i32) nounwind
+declare <8 x i16> @llvm.arm.neon.vld1.v8i16.p0(ptr, i32) nounwind readonly
+declare void @llvm.arm.neon.vst1.p0.v8i16(ptr, <8 x i16>, i32) nounwind
; CHECK: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }
; CHECK: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
; BasicAA should prove that these calls don't interfere, since they are
; IntrArgReadMem and have noalias pointers.
-; CHECK: define <8 x i16> @test0(<8 x i16>* noalias %p, <8 x i16>* noalias %q, <8 x i16> %y, <8 x i1> %m, <8 x i16> %pt) {
+; CHECK: define <8 x i16> @test0(ptr noalias %p, ptr noalias %q, <8 x i16> %y, <8 x i1> %m, <8 x i16> %pt) {
; CHECK-NEXT: entry:
-; CHECK-NEXT: %a = call <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>* %p, i32 16, <8 x i1> %m, <8 x i16> %pt) [[ATTR:#[0-9]+]]
-; CHECK-NEXT: call void @llvm.masked.store.v8i16.p0v8i16(<8 x i16> %y, <8 x i16>* %q, i32 16, <8 x i1> %m)
+; CHECK-NEXT: %a = call <8 x i16> @llvm.masked.load.v8i16.p0(ptr %p, i32 16, <8 x i1> %m, <8 x i16> %pt) [[ATTR:#[0-9]+]]
+; CHECK-NEXT: call void @llvm.masked.store.v8i16.p0(<8 x i16> %y, ptr %q, i32 16, <8 x i1> %m)
; CHECK-NEXT: %c = add <8 x i16> %a, %a
-define <8 x i16> @test0(<8 x i16>* noalias %p, <8 x i16>* noalias %q, <8 x i16> %y, <8 x i1> %m, <8 x i16> %pt) {
+define <8 x i16> @test0(ptr noalias %p, ptr noalias %q, <8 x i16> %y, <8 x i1> %m, <8 x i16> %pt) {
entry:
- %a = call <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>* %p, i32 16, <8 x i1> %m, <8 x i16> %pt) nounwind
- call void @llvm.masked.store.v8i16.p0v8i16(<8 x i16> %y, <8 x i16>* %q, i32 16, <8 x i1> %m)
- %b = call <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>* %p, i32 16, <8 x i1> %m, <8 x i16> %pt) nounwind
+ %a = call <8 x i16> @llvm.masked.load.v8i16.p0(ptr %p, i32 16, <8 x i1> %m, <8 x i16> %pt) nounwind
+ call void @llvm.masked.store.v8i16.p0(<8 x i16> %y, ptr %q, i32 16, <8 x i1> %m)
+ %b = call <8 x i16> @llvm.masked.load.v8i16.p0(ptr %p, i32 16, <8 x i1> %m, <8 x i16> %pt) nounwind
%c = add <8 x i16> %a, %b
ret <8 x i16> %c
}
-declare <8 x i16> @llvm.masked.load.v8i16.p0v8i16(<8 x i16>*, i32, <8 x i1>, <8 x i16>) nounwind readonly
-declare void @llvm.masked.store.v8i16.p0v8i16(<8 x i16>, <8 x i16>*, i32, <8 x i1>) nounwind
+declare <8 x i16> @llvm.masked.load.v8i16.p0(ptr, i32, <8 x i1>, <8 x i16>) nounwind readonly
+declare void @llvm.masked.store.v8i16.p0(<8 x i16>, ptr, i32, <8 x i1>) nounwind
; CHECK: attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }
; CHECK: attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: write) }
; return *p + 1;
; }
-define i32 @foo(i32* nocapture %p, i8* nocapture %q) {
+define i32 @foo(ptr nocapture %p, ptr nocapture %q) {
entry:
- %0 = load i32, i32* %p, align 4, !invariant.load !3
+ %0 = load i32, ptr %p, align 4, !invariant.load !3
%conv = trunc i32 %0 to i8
- store i8 %conv, i8* %q, align 1
- %1 = load i32, i32* %p, align 4, !invariant.load !3
+ store i8 %conv, ptr %q, align 1
+ %1 = load i32, ptr %p, align 4, !invariant.load !3
%add = add nsw i32 %1, 1
ret i32 %add
; CHECK: foo
-; CHECK: %0 = load i32, i32* %p
-; CHECK: store i8 %conv, i8* %q,
+; CHECK: %0 = load i32, ptr %p
+; CHECK: store i8 %conv, ptr %q,
; CHECK: %add = add nsw i32 %0, 1
}
; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn,dse -S | FileCheck %s
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
-declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
+declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
-declare void @external(i32*)
+declare void @external(ptr)
-define i32 @test0(i8* %P) {
+define i32 @test0(ptr %P) {
; CHECK-LABEL: @test0(
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
-; CHECK-NEXT: call void @external(i32* [[A]])
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* [[P:%.*]], i8 0, i32 42, i1 false)
+; CHECK-NEXT: call void @external(ptr [[A]])
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr [[P:%.*]], i8 0, i32 42, i1 false)
; CHECK-NEXT: ret i32 0
;
%A = alloca i32
- call void @external(i32* %A)
+ call void @external(ptr %A)
- store i32 0, i32* %A
+ store i32 0, ptr %A
- call void @llvm.memset.p0i8.i32(i8* %P, i8 0, i32 42, i1 false)
+ call void @llvm.memset.p0.i32(ptr %P, i8 0, i32 42, i1 false)
- %B = load i32, i32* %A
+ %B = load i32, ptr %A
ret i32 %B
}
%A = alloca i8
%B = alloca i8
- store i8 2, i8* %B ;; Not written to by memcpy
+ store i8 2, ptr %B ;; Not written to by memcpy
- call void @llvm.memcpy.p0i8.p0i8.i8(i8* %A, i8* %B, i8 -1, i1 false)
+ call void @llvm.memcpy.p0.p0.i8(ptr %A, ptr %B, i8 -1, i1 false)
- %C = load i8, i8* %B
+ %C = load i8, ptr %B
ret i8 %C
}
-define i8 @test2(i8* %P) {
+define i8 @test2(ptr %P) {
; CHECK-LABEL: @test2(
-; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, i8* [[P:%.*]], i32 127
-; CHECK-NEXT: store i8 1, i8* [[P2]], align 1
-; CHECK-NEXT: call void @llvm.memset.p0i8.i8(i8* [[P]], i8 2, i8 127, i1 false)
+; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 127
+; CHECK-NEXT: store i8 1, ptr [[P2]], align 1
+; CHECK-NEXT: call void @llvm.memset.p0.i8(ptr [[P]], i8 2, i8 127, i1 false)
; CHECK-NEXT: ret i8 1
;
- %P2 = getelementptr i8, i8* %P, i32 127
- store i8 1, i8* %P2 ;; Not dead across memset
- call void @llvm.memset.p0i8.i8(i8* %P, i8 2, i8 127, i1 false)
- %A = load i8, i8* %P2
+ %P2 = getelementptr i8, ptr %P, i32 127
+ store i8 1, ptr %P2 ;; Not dead across memset
+ call void @llvm.memset.p0.i8(ptr %P, i8 2, i8 127, i1 false)
+ %A = load i8, ptr %P2
ret i8 %A
}
-define i8 @test2a(i8* %P) {
+define i8 @test2a(ptr %P) {
; CHECK-LABEL: @test2a(
-; CHECK-NEXT: call void @llvm.memset.p0i8.i8(i8* [[P:%.*]], i8 2, i8 127, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i8(ptr [[P:%.*]], i8 2, i8 127, i1 false)
; CHECK-NEXT: ret i8 2
;
- %P2 = getelementptr i8, i8* %P, i32 126
+ %P2 = getelementptr i8, ptr %P, i32 126
- store i8 1, i8* %P2 ;; Dead, clobbered by memset.
+ store i8 1, ptr %P2 ;; Dead, clobbered by memset.
- call void @llvm.memset.p0i8.i8(i8* %P, i8 2, i8 127, i1 false)
- %A = load i8, i8* %P2
+ call void @llvm.memset.p0.i8(ptr %P, i8 2, i8 127, i1 false)
+ %A = load i8, ptr %P2
ret i8 %A
}
-define void @test3(i8* %P, i8 %X) {
+define void @test3(ptr %P, i8 %X) {
; CHECK-LABEL: @test3(
-; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, i8* [[P:%.*]], i32 2
-; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[P]])
-; CHECK-NEXT: store i8 2, i8* [[P2]], align 1
+; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[P:%.*]], i32 2
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[P]])
+; CHECK-NEXT: store i8 2, ptr [[P2]], align 1
; CHECK-NEXT: ret void
;
%Y = add i8 %X, 1 ;; Dead, because the only use (the store) is dead.
- %P2 = getelementptr i8, i8* %P, i32 2
- store i8 %Y, i8* %P2 ;; Not read by lifetime.end, should be removed.
- call void @llvm.lifetime.end.p0i8(i64 1, i8* %P)
- store i8 2, i8* %P2
+ %P2 = getelementptr i8, ptr %P, i32 2
+ store i8 %Y, ptr %P2 ;; Not read by lifetime.end, should be removed.
+ call void @llvm.lifetime.end.p0(i64 1, ptr %P)
+ store i8 2, ptr %P2
ret void
}
-define void @test3a(i8* %P, i8 %X) {
+define void @test3a(ptr %P, i8 %X) {
; CHECK-LABEL: @test3a(
-; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 10, i8* [[P:%.*]])
+; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 10, ptr [[P:%.*]])
; CHECK-NEXT: ret void
;
%Y = add i8 %X, 1 ;; Dead, because the only use (the store) is dead.
- %P2 = getelementptr i8, i8* %P, i32 2
- store i8 %Y, i8* %P2
- call void @llvm.lifetime.end.p0i8(i64 10, i8* %P)
+ %P2 = getelementptr i8, ptr %P, i32 2
+ store i8 %Y, ptr %P2
+ call void @llvm.lifetime.end.p0(i64 10, ptr %P)
ret void
}
@G1 = external global i32
@G2 = external global [4000 x i32]
-define i32 @test4(i8* %P) {
+define i32 @test4(ptr %P) {
; CHECK-LABEL: @test4(
-; CHECK-NEXT: call void @llvm.memset.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8 0, i32 4000, i1 false)
+; CHECK-NEXT: call void @llvm.memset.p0.i32(ptr @G2, i8 0, i32 4000, i1 false)
; CHECK-NEXT: ret i32 0
;
- %tmp = load i32, i32* @G1
- call void @llvm.memset.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8 0, i32 4000, i1 false)
- %tmp2 = load i32, i32* @G1
+ %tmp = load i32, ptr @G1
+ call void @llvm.memset.p0.i32(ptr @G2, i8 0, i32 4000, i1 false)
+ %tmp2 = load i32, ptr @G1
%sub = sub i32 %tmp2, %tmp
ret i32 %sub
}
; Verify that basicaa is handling variable length memcpy, knowing it doesn't
; write to G1.
-define i32 @test5(i8* %P, i32 %Len) {
+define i32 @test5(ptr %P, i32 %Len) {
; CHECK-LABEL: @test5(
-; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8* bitcast (i32* @G1 to i8*), i32 [[LEN:%.*]], i1 false)
+; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr @G2, ptr @G1, i32 [[LEN:%.*]], i1 false)
; CHECK-NEXT: ret i32 0
;
- %tmp = load i32, i32* @G1
- call void @llvm.memcpy.p0i8.p0i8.i32(i8* bitcast ([4000 x i32]* @G2 to i8*), i8* bitcast (i32* @G1 to i8*), i32 %Len, i1 false)
- %tmp2 = load i32, i32* @G1
+ %tmp = load i32, ptr @G1
+ call void @llvm.memcpy.p0.p0.i32(ptr @G2, ptr @G1, i32 %Len, i1 false)
+ %tmp2 = load i32, ptr @G1
%sub = sub i32 %tmp2, %tmp
ret i32 %sub
}
-define i8 @test6(i8* %p, i8* noalias %a) {
+define i8 @test6(ptr %p, ptr noalias %a) {
; CHECK-LABEL: @test6(
-; CHECK-NEXT: [[X:%.*]] = load i8, i8* [[A:%.*]], align 1
-; CHECK-NEXT: [[T:%.*]] = va_arg i8* [[P:%.*]], float
+; CHECK-NEXT: [[X:%.*]] = load i8, ptr [[A:%.*]], align 1
+; CHECK-NEXT: [[T:%.*]] = va_arg ptr [[P:%.*]], float
; CHECK-NEXT: [[Z:%.*]] = add i8 [[X]], [[X]]
; CHECK-NEXT: ret i8 [[Z]]
;
- %x = load i8, i8* %a
- %t = va_arg i8* %p, float
- %y = load i8, i8* %a
+ %x = load i8, ptr %a
+ %t = va_arg ptr %p, float
+ %y = load i8, ptr %a
%z = add i8 %x, %y
ret i8 %z
}
; PR10628
-declare void @test7decl(i32* nocapture %x)
+declare void @test7decl(ptr nocapture %x)
define i32 @test7() nounwind uwtable ssp {
; CHECK-LABEL: @test7(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
-; CHECK-NEXT: store i32 0, i32* [[X]], align 4
-; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, i32* [[X]], i64 1
-; CHECK-NEXT: call void @test7decl(i32* [[ADD_PTR]])
-; CHECK-NEXT: [[TMP:%.*]] = load i32, i32* [[X]], align 4
+; CHECK-NEXT: store i32 0, ptr [[X]], align 4
+; CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr [[X]], i64 1
+; CHECK-NEXT: call void @test7decl(ptr [[ADD_PTR]])
+; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr [[X]], align 4
; CHECK-NEXT: ret i32 [[TMP]]
;
entry:
%x = alloca i32, align 4
- store i32 0, i32* %x, align 4
- %add.ptr = getelementptr inbounds i32, i32* %x, i64 1
- call void @test7decl(i32* %add.ptr)
- %tmp = load i32, i32* %x, align 4
+ store i32 0, ptr %x, align 4
+ %add.ptr = getelementptr inbounds i32, ptr %x, i64 1
+ call void @test7decl(ptr %add.ptr)
+ %tmp = load i32, ptr %x, align 4
ret i32 %tmp
}
;; Check that aa correctly handles functions marked with argmemonly
;; attribute.
-declare i32 @func_argmemonly(i32 * %P) argmemonly
+declare i32 @func_argmemonly(ptr %P) argmemonly
;; Can not remove redundant load, function may write to it.
-define i32 @test8(i32 *%P) {
+define i32 @test8(ptr %P) {
; CHECK-LABEL: @test8(
-; CHECK-NEXT: [[V1:%.*]] = load i32, i32* [[P:%.*]], align 4
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(i32* [[P]])
-; CHECK-NEXT: [[V2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(ptr [[P]])
+; CHECK-NEXT: [[V2:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[V1]], [[V2]]
; CHECK-NEXT: ret i32 [[DIFF]]
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly(i32* %P)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly(ptr %P)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
;; In this case load can be removed, function clobbers only %P2.
-define i32 @test9(i32* %P, i32* noalias %P2) {
+define i32 @test9(ptr %P, ptr noalias %P2) {
; CHECK-LABEL: @test9(
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(i32* [[P2:%.*]])
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(ptr [[P2:%.*]])
; CHECK-NEXT: ret i32 0
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly(i32* %P2)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly(ptr %P2)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
;; In this case load can *not* be removed. Function clobers only %P2 but it may
;; alias with %P.
-define i32 @test10(i32* %P, i32* %P2) {
+define i32 @test10(ptr %P, ptr %P2) {
; CHECK-LABEL: @test10(
-; CHECK-NEXT: [[V1:%.*]] = load i32, i32* [[P:%.*]], align 4
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(i32* [[P2:%.*]])
-; CHECK-NEXT: [[V2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(ptr [[P2:%.*]])
+; CHECK-NEXT: [[V2:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[V1]], [[V2]]
; CHECK-NEXT: ret i32 [[DIFF]]
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly(i32* %P2)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly(ptr %P2)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
-define i32 @test11(i32* %P, i32* %P2) {
+define i32 @test11(ptr %P, ptr %P2) {
; CHECK-LABEL: @test11(
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(i32* readonly [[P2:%.*]])
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(ptr readonly [[P2:%.*]])
; CHECK-NEXT: ret i32 0
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly(i32* readonly %P2)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly(ptr readonly %P2)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
-declare i32 @func_argmemonly_two_args(i32* %P, i32* %P2) argmemonly
+declare i32 @func_argmemonly_two_args(ptr %P, ptr %P2) argmemonly
-define i32 @test12(i32* %P, i32* %P2, i32* %P3) {
+define i32 @test12(ptr %P, ptr %P2, ptr %P3) {
; CHECK-LABEL: @test12(
-; CHECK-NEXT: [[V1:%.*]] = load i32, i32* [[P:%.*]], align 4
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly_two_args(i32* readonly [[P2:%.*]], i32* [[P3:%.*]])
-; CHECK-NEXT: [[V2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: [[V1:%.*]] = load i32, ptr [[P:%.*]], align 4
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly_two_args(ptr readonly [[P2:%.*]], ptr [[P3:%.*]])
+; CHECK-NEXT: [[V2:%.*]] = load i32, ptr [[P]], align 4
; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[V1]], [[V2]]
; CHECK-NEXT: ret i32 [[DIFF]]
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly_two_args(i32* readonly %P2, i32* %P3)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly_two_args(ptr readonly %P2, ptr %P3)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
-define i32 @test13(i32* %P, i32* %P2) {
+define i32 @test13(ptr %P, ptr %P2) {
; CHECK-LABEL: @test13(
-; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(i32* readnone [[P2:%.*]])
+; CHECK-NEXT: [[TMP1:%.*]] = call i32 @func_argmemonly(ptr readnone [[P2:%.*]])
; CHECK-NEXT: ret i32 0
;
- %V1 = load i32, i32* %P
- call i32 @func_argmemonly(i32* readnone %P2)
- %V2 = load i32, i32* %P
+ %V1 = load i32, ptr %P
+ call i32 @func_argmemonly(ptr readnone %P2)
+ %V2 = load i32, ptr %P
%Diff = sub i32 %V1, %V2
ret i32 %Diff
}
-declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) nounwind
-declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i1) nounwind
-declare void @llvm.memcpy.p0i8.p0i8.i8(i8* nocapture, i8* nocapture, i8, i1) nounwind
-declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i1) nounwind
+declare void @llvm.memset.p0.i32(ptr nocapture, i8, i32, i1) nounwind
+declare void @llvm.memset.p0.i8(ptr nocapture, i8, i8, i1) nounwind
+declare void @llvm.memcpy.p0.p0.i8(ptr nocapture, ptr nocapture, i8, i1) nounwind
+declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn,instcombine -S | FileCheck %s
-declare i32* @test(i32* nocapture)
+declare ptr @test(ptr nocapture)
define i32 @test2() {
; CHECK: ret i32 0
%P = alloca i32
- %Q = call i32* @test(i32* %P)
- %a = load i32, i32* %P
- store i32 4, i32* %Q ;; cannot clobber P since it is nocapture.
- %b = load i32, i32* %P
+ %Q = call ptr @test(ptr %P)
+ %a = load i32, ptr %P
+ store i32 4, ptr %Q ;; cannot clobber P since it is nocapture.
+ %b = load i32, ptr %P
%c = sub i32 %a, %b
ret i32 %c
}
-declare void @test3(i32** %p, i32* %q) nounwind
+declare void @test3(ptr %p, ptr %q) nounwind
-define i32 @test4(i32* noalias nocapture %p) nounwind {
+define i32 @test4(ptr noalias nocapture %p) nounwind {
; CHECK: call void @test3
-; CHECK: store i32 0, i32* %p
-; CHECK: store i32 1, i32* %x
-; CHECK: %y = load i32, i32* %p
+; CHECK: store i32 0, ptr %p
+; CHECK: store i32 1, ptr %x
+; CHECK: %y = load i32, ptr %p
; CHECK: ret i32 %y
entry:
- %q = alloca i32*
+ %q = alloca ptr
; Here test3 might store %p to %q. This doesn't violate %p's nocapture
; attribute since the copy doesn't outlive the function.
- call void @test3(i32** %q, i32* %p) nounwind
- store i32 0, i32* %p
- %x = load i32*, i32** %q
+ call void @test3(ptr %q, ptr %p) nounwind
+ store i32 0, ptr %p
+ %x = load ptr, ptr %q
; This store might write to %p and so we can't eliminate the subsequent
; load
- store i32 1, i32* %x
- %y = load i32, i32* %p
+ store i32 1, ptr %x
+ %y = load i32, ptr %p
ret i32 %y
}
; CHECK: %tmp0 = call i32 @TestConst(i32 5) [[READNONE:#[0-9]+]]
; CHECK-NEXT: %tmp1 = call i32 @TestPure(i32 6) [[READONLY:#[0-9]+]]
; CHECK-NEXT: %tmp2 = call i32 @TestNone(i32 7)
-; CHECK-NEXT: store i32 1, i32* @g
+; CHECK-NEXT: store i32 1, ptr @g
; CHECK-NEXT: %tmp5 = call i32 @TestPure(i32 6) [[READONLY]]
; CHECK-NEXT: %tmp7 = call i32 @TestNone(i32 7)
; CHECK-NEXT: %tmp8 = call i32 @TestNone(i32 7)
%tmp0 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
%tmp1 = call i32 @TestPure( i32 6 ) readonly ; <i32> [#uses=1]
%tmp2 = call i32 @TestNone( i32 7 ) ; <i32> [#uses=1]
- store i32 1, i32* @g
+ store i32 1, ptr @g
%tmp3 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
%tmp4 = call i32 @TestConst( i32 5 ) readnone ; <i32> [#uses=1]
%tmp5 = call i32 @TestPure( i32 6 ) readonly ; <i32> [#uses=1]
; RUN: opt < %s -aa-pipeline=basic-aa -passes='loop-mssa(licm)' -S | FileCheck %s
target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
-@A = global i32 7 ; <i32*> [#uses=3]
-@B = global i32 8 ; <i32*> [#uses=2]
-@C = global [2 x i32] [ i32 4, i32 8 ] ; <[2 x i32]*> [#uses=2]
+@A = global i32 7 ; <ptr> [#uses=3]
+@B = global i32 8 ; <ptr> [#uses=2]
+@C = global [2 x i32] [ i32 4, i32 8 ] ; <ptr> [#uses=2]
define i32 @test1(i1 %c) {
- %Atmp = load i32, i32* @A ; <i32> [#uses=2]
+ %Atmp = load i32, ptr @A ; <i32> [#uses=2]
br label %Loop
Loop: ; preds = %Loop, %0
- %ToRemove = load i32, i32* @A ; <i32> [#uses=1]
- store i32 %Atmp, i32* @B
+ %ToRemove = load i32, ptr @A ; <i32> [#uses=1]
+ store i32 %Atmp, ptr @B
br i1 %c, label %Out, label %Loop
Out: ; preds = %Loop
; The Loop block should be empty after the load/store are promoted.
; CHECK: @test1
-; CHECK: load i32, i32* @A
-; CHECK: load i32, i32* @A
-; CHECK: store i32 %Atmp, i32* @B
+; CHECK: load i32, ptr @A
+; CHECK: load i32, ptr @A
+; CHECK: store i32 %Atmp, ptr @B
; CHECK: Loop:
; CHECK-NEXT: br i1 %c, label %Out, label %Loop
; CHECK: Out:
br label %Loop
Loop: ; preds = %Loop, %0
- %AVal = load i32, i32* @A ; <i32> [#uses=2]
- %C0 = getelementptr [2 x i32], [2 x i32]* @C, i64 0, i64 0 ; <i32*> [#uses=1]
- store i32 %AVal, i32* %C0
- %BVal = load i32, i32* @B ; <i32> [#uses=2]
- %C1 = getelementptr [2 x i32], [2 x i32]* @C, i64 0, i64 1 ; <i32*> [#uses=1]
- store i32 %BVal, i32* %C1
+ %AVal = load i32, ptr @A ; <i32> [#uses=2]
+ %C0 = getelementptr [2 x i32], ptr @C, i64 0, i64 0 ; <ptr> [#uses=1]
+ store i32 %AVal, ptr %C0
+ %BVal = load i32, ptr @B ; <i32> [#uses=2]
+ %C1 = getelementptr [2 x i32], ptr @C, i64 0, i64 1 ; <ptr> [#uses=1]
+ store i32 %BVal, ptr %C1
br i1 %c, label %Out, label %Loop
Out: ; preds = %Loop