================
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls 
-fptrauth-intrinsics -emit-llvm -o-  
-fptrauth-function-pointer-type-discrimination | FileCheck %s
+
+typedef void (*fptr_t)(void);
+
+char *cptr;
+void (*fptr)(void);
+
+// CHECK-LABEL: define void @test1
+void test1() {
+  // CHECK: [[LOAD:%.*]] = load ptr, ptr @cptr
+  // CHECK: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
+  // CHECK: call i64 @llvm.ptrauth.resign(i64 [[TOINT]], i32 0, i64 0, i32 0, 
i64 18983)
+  // CHECK: call void {{.*}}() [ "ptrauth"(i32 0, i64 18983) ]
+
+  (*(fptr_t)cptr)();
+}
+
+// CHECK-LABEL: define i8 @test2
+char test2() {
+  return *(char *)fptr;
+
+  // CHECK: [[LOAD:%.*]] = load ptr, ptr @fptr
+  // CHECK: [[CMP:%.*]] = icmp ne ptr [[LOAD]], null
+
+  // CHECK: [[TOINT:%.*]] = ptrtoint ptr [[LOAD]] to i64
----------------
kovdan01 wrote:

Here, you don't check the full function body, and only partially check 
instructions after `resign.nonnull:` label. The `resign.cont:` label is left 
unchecked. Was it done intentionally?

https://github.com/llvm/llvm-project/pull/98847
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to