blob: f98807c255383063f06a544884b4f46f6e7ef52a [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5
; RUN: opt -passes=pre-isel-intrinsic-lowering -S < %s | FileCheck --check-prefix=NOPAUTH %s
; RUN: opt -passes=pre-isel-intrinsic-lowering -mattr=+pauth -S < %s | FileCheck --check-prefix=PAUTH %s
target triple = "aarch64-unknown-linux-gnu"
@ds1 = external global i8
@ds2 = external global i8
@ds3 = external global i8
@ds4 = external global i8
;.
; NOPAUTH: @ds1 = external global i8
; NOPAUTH: @ds2 = external global i8
; NOPAUTH: @ds3 = external global i8
; NOPAUTH: @ds4 = hidden alias i8, inttoptr (i64 3573751839 to ptr)
;.
; PAUTH: @ds1 = external global i8
; PAUTH: @ds2 = external global i8
; PAUTH: @ds3 = external global i8
; PAUTH: @ds4 = hidden alias i8, inttoptr (i64 3573751839 to ptr)
;.
define ptr @load_hw(ptr addrspace(1) %ptrptr) {
; NOPAUTH-LABEL: define ptr @load_hw(
; NOPAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) {
; NOPAUTH-NEXT: [[PTR:%.*]] = load ptr, ptr addrspace(1) [[PTRPTR]], align 8
; NOPAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
; NOPAUTH-NEXT: [[TMP2:%.*]] = call i64 @__emupac_autda(i64 [[TMP1]], i64 1) [ "deactivation-symbol"(ptr @ds1) ]
; NOPAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; NOPAUTH-NEXT: ret ptr [[TMP3]]
;
; PAUTH-LABEL: define ptr @load_hw(
; PAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) #[[ATTR0:[0-9]+]] {
; PAUTH-NEXT: [[PTR:%.*]] = load ptr, ptr addrspace(1) [[PTRPTR]], align 8
; PAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
; PAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.auth(i64 [[TMP1]], i32 2, i64 1) [ "deactivation-symbol"(ptr @ds1) ]
; PAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; PAUTH-NEXT: ret ptr [[TMP3]]
;
%protptrptr = call ptr addrspace(1) @llvm.protected.field.ptr.p1(ptr addrspace(1) %ptrptr, i64 1, i1 true) [ "deactivation-symbol"(ptr @ds1) ]
%ptr = load ptr, ptr addrspace(1) %protptrptr
ret ptr %ptr
}
define void @store_hw(ptr addrspace(1) %ptrptr, ptr %ptr) {
; NOPAUTH-LABEL: define void @store_hw(
; NOPAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]], ptr [[PTR:%.*]]) {
; NOPAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
; NOPAUTH-NEXT: [[TMP2:%.*]] = call i64 @__emupac_pacda(i64 [[TMP1]], i64 2) [ "deactivation-symbol"(ptr @ds2) ]
; NOPAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; NOPAUTH-NEXT: store ptr [[TMP3]], ptr addrspace(1) [[PTRPTR]], align 8
; NOPAUTH-NEXT: ret void
;
; PAUTH-LABEL: define void @store_hw(
; PAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]], ptr [[PTR:%.*]]) #[[ATTR0]] {
; PAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64
; PAUTH-NEXT: [[TMP2:%.*]] = call i64 @llvm.ptrauth.sign(i64 [[TMP1]], i32 2, i64 2) [ "deactivation-symbol"(ptr @ds2) ]
; PAUTH-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; PAUTH-NEXT: store ptr [[TMP3]], ptr addrspace(1) [[PTRPTR]], align 8
; PAUTH-NEXT: ret void
;
%protptrptr = call ptr addrspace(1) @llvm.protected.field.ptr.p1(ptr addrspace(1) %ptrptr, i64 2, i1 true) [ "deactivation-symbol"(ptr @ds2) ]
store ptr %ptr, ptr addrspace(1) %protptrptr
ret void
}
define i1 @compare(ptr addrspace(1) %ptrptr) {
; NOPAUTH-LABEL: define i1 @compare(
; NOPAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) {
; NOPAUTH-NEXT: [[CMP1:%.*]] = icmp eq ptr addrspace(1) [[PTRPTR]], null
; NOPAUTH-NEXT: [[CMP2:%.*]] = icmp eq ptr addrspace(1) null, [[PTRPTR]]
; NOPAUTH-NEXT: [[CMP:%.*]] = or i1 [[CMP1]], [[CMP2]]
; NOPAUTH-NEXT: ret i1 [[CMP]]
;
; PAUTH-LABEL: define i1 @compare(
; PAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) #[[ATTR0]] {
; PAUTH-NEXT: [[CMP1:%.*]] = icmp eq ptr addrspace(1) [[PTRPTR]], null
; PAUTH-NEXT: [[CMP2:%.*]] = icmp eq ptr addrspace(1) null, [[PTRPTR]]
; PAUTH-NEXT: [[CMP:%.*]] = or i1 [[CMP1]], [[CMP2]]
; PAUTH-NEXT: ret i1 [[CMP]]
;
%protptrptr = call ptr addrspace(1) @llvm.protected.field.ptr.p1(ptr addrspace(1) %ptrptr, i64 3, i1 true) [ "deactivation-symbol"(ptr @ds3) ]
%cmp1 = icmp eq ptr addrspace(1) %protptrptr, null
%cmp2 = icmp eq ptr addrspace(1) null, %protptrptr
%cmp = or i1 %cmp1, %cmp2
ret i1 %cmp
}
define ptr addrspace(1) @escape(ptr addrspace(1) %ptrptr) {
; NOPAUTH-LABEL: define ptr addrspace(1) @escape(
; NOPAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) {
; NOPAUTH-NEXT: ret ptr addrspace(1) [[PTRPTR]]
;
; PAUTH-LABEL: define ptr addrspace(1) @escape(
; PAUTH-SAME: ptr addrspace(1) [[PTRPTR:%.*]]) #[[ATTR0]] {
; PAUTH-NEXT: ret ptr addrspace(1) [[PTRPTR]]
;
%protptrptr = call ptr addrspace(1) @llvm.protected.field.ptr.p1(ptr addrspace(1) %ptrptr, i64 3, i1 true) [ "deactivation-symbol"(ptr @ds4) ]
ret ptr addrspace(1) %protptrptr
}
declare ptr addrspace(1) @llvm.protected.field.ptr.p1(ptr addrspace(1), i64, i1 immarg)
;.
; NOPAUTH: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(none) }
; NOPAUTH: attributes #[[ATTR1:[0-9]+]] = { nounwind memory(none) }
;.
; PAUTH: attributes #[[ATTR0]] = { "target-features"="+pauth" }
; PAUTH: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(none) "target-features"="+pauth" }
; PAUTH: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(none) }
; PAUTH: attributes #[[ATTR3:[0-9]+]] = { nounwind memory(none) }
;.