1; Test upgrade of ptr.annotation intrinsics.
2;
3; RUN: llvm-dis < %s.bc | FileCheck %s
4
5; Unused return values
6; The arguments passed to the intrinisic wouldn't normally be arguments to
7; the function, but that makes it easier to test that they are handled
8; correctly.
9define void @f1(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3) {
10;CHECK: @f1(i8* [[ARG0:%.*]], i8* [[ARG1:%.*]], i8* [[ARG2:%.*]], i32 [[ARG3:%.*]])
11  %t0 = call i8* @llvm.ptr.annotation.p0i8(i8* %arg0, i8* %arg1, i8* %arg2, i32 %arg3)
12;CHECK:  call i8* @llvm.ptr.annotation.p0i8(i8* [[ARG0]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
13
14  %arg0_p16 = bitcast i8* %arg0 to i16*
15  %t1 = call i16* @llvm.ptr.annotation.p0i16(i16* %arg0_p16, i8* %arg1, i8* %arg2, i32 %arg3)
16;CHECK:  [[ARG0_P16:%.*]] = bitcast
17;CHECK:  call i16* @llvm.ptr.annotation.p0i16(i16* [[ARG0_P16]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
18
19  %arg0_p256 = bitcast i8* %arg0 to i256*
20  %t2 = call i256* @llvm.ptr.annotation.p0i256(i256* %arg0_p256, i8* %arg1, i8* %arg2, i32 %arg3)
21;CHECK:  [[ARG0_P256:%.*]] = bitcast
22;CHECK:  call i256* @llvm.ptr.annotation.p0i256(i256* [[ARG0_P256]], i8* [[ARG1]], i8* [[ARG2]], i32 [[ARG3]], i8* null)
23  ret void
24}
25
26; Used return values
27define i16* @f2(i16* %x, i16* %y) {
28  %t0 = call i16* @llvm.ptr.annotation.p0i16(i16* %x, i8* undef, i8* undef, i32 undef)
29  %t1 = call i16* @llvm.ptr.annotation.p0i16(i16* %y, i8* undef, i8* undef, i32 undef)
30  %cmp = icmp ugt i16* %t0, %t1
31  %sel = select i1 %cmp, i16* %t0, i16* %t1
32  ret i16* %sel
33; CHECK:  [[T0:%.*]] = call i16* @llvm.ptr.annotation.p0i16(i16* %x, i8* undef, i8* undef, i32 undef, i8* null)
34; CHECK:  [[T1:%.*]] = call i16* @llvm.ptr.annotation.p0i16(i16* %y, i8* undef, i8* undef, i32 undef, i8* null)
35; CHECK:  %cmp = icmp ugt i16* [[T0]], [[T1]]
36; CHECK:  %sel = select i1 %cmp, i16* [[T0]], i16* [[T1]]
37; CHECK:  ret i16* %sel
38}
39
40declare i8*   @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32)
41; CHECK: declare i8*   @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)
42declare i16*  @llvm.ptr.annotation.p0i16(i16*, i8*, i8*, i32)
43; CHECK: declare i16*   @llvm.ptr.annotation.p0i16(i16*, i8*, i8*, i32, i8*)
44declare i256* @llvm.ptr.annotation.p0i256(i256*, i8*, i8*, i32)
45; CHECK: declare i256*   @llvm.ptr.annotation.p0i256(i256*, i8*, i8*, i32, i8*)
46