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