================ @@ -0,0 +1,167 @@ +; 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 +@ds5 = external global i8 +@ds6 = external global i8 + +;. +; NOPAUTH: @ds1 = external global i8 +; NOPAUTH: @ds2 = external global i8 +; NOPAUTH: @ds3 = external global i8 +; NOPAUTH: @ds4 = external global i8 +; NOPAUTH: @ds5 = external global i8 +; NOPAUTH: @ds6 = 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 = external global i8 +; PAUTH: @ds5 = external global i8 +; PAUTH: @ds6 = hidden alias i8, inttoptr (i64 3573751839 to ptr) +;. +define ptr @load_hw(ptr %ptrptr) { +; NOPAUTH-LABEL: define ptr @load_hw( +; NOPAUTH-SAME: ptr [[PTRPTR:%.*]]) { +; NOPAUTH-NEXT: [[PTR:%.*]] = load ptr, ptr [[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 [[PTRPTR:%.*]]) #[[ATTR0:[0-9]+]] { +; PAUTH-NEXT: [[PTR:%.*]] = load ptr, ptr [[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 @llvm.protected.field.ptr(ptr %ptrptr, i64 1, i1 true) [ "deactivation-symbol"(ptr @ds1) ] + %ptr = load ptr, ptr %protptrptr + ret ptr %ptr +} + +define void @store_hw(ptr %ptrptr, ptr %ptr) { +; NOPAUTH-LABEL: define void @store_hw( +; NOPAUTH-SAME: ptr [[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 [[PTRPTR]], align 8 +; NOPAUTH-NEXT: ret void +; +; PAUTH-LABEL: define void @store_hw( +; PAUTH-SAME: ptr [[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 [[PTRPTR]], align 8 +; PAUTH-NEXT: ret void +; + %protptrptr = call ptr @llvm.protected.field.ptr(ptr %ptrptr, i64 2, i1 true) [ "deactivation-symbol"(ptr @ds2) ] + store ptr %ptr, ptr %protptrptr + ret void +} + +define ptr @load_sw(ptr %ptrptr) { +; NOPAUTH-LABEL: define ptr @load_sw( +; NOPAUTH-SAME: ptr [[PTRPTR:%.*]]) { +; NOPAUTH-NEXT: [[PTR:%.*]] = load ptr, ptr [[PTRPTR]], align 8 +; NOPAUTH-NEXT: [[TMP1:%.*]] = ptrtoint ptr [[PTR]] to i64 +; NOPAUTH-NEXT: [[TMP2:%.*]] = add i64 [[TMP1]], 1 +; NOPAUTH-NEXT: [[TMP3:%.*]] = call i64 @llvm.fshr.i64(i64 [[TMP2]], i64 [[TMP2]], i64 16) ---------------- nikic wrote:
Something I don't get is how the deactivation is going to work in the non-hw case. You don't attach the deactivation symbol anywhere here (and in fact, cannot attach it to all the relevant instructions, as the add is not a call). https://github.com/llvm/llvm-project/pull/151647 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits