[llvm] [PtrAuth] Add ConstantPtrAuth comparator to FunctionComparator.cpp (PR #159480)

Oskar Wirga via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 22 13:08:48 PST 2025


================
@@ -0,0 +1,130 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -passes=mergefunc -S < %s | FileCheck %s
+; Ensure MergeFunc handles ConstantPtrAuth correctly and does not
+; merge when any ptrauth operand differs (ptr, key, int disc, addr disc).
+
+target triple = "arm64e-apple-ios14.0.0"
+
+declare void @baz()
+ at ADDR = external global i8
+
+declare void @callee(ptr)
+
+; different base pointer (null vs @baz)
+
+define i32 @f_ptr_null() {
+; CHECK-LABEL: define i32 @f_ptr_null() {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    call void @callee(ptr ptrauth (ptr null, i32 0))
+; CHECK-NEXT:    ret i32 1
+;
+entry:
+  call void @callee(ptr ptrauth (ptr null, i32 0))
+  ret i32 1
+}
+
+define i32 @g_ptr_baz() {
+; CHECK-LABEL: define i32 @g_ptr_baz() {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    call void @callee(ptr ptrauth (ptr @baz, i32 0))
+; CHECK-NEXT:    ret i32 2
+;
+entry:
+  call void @callee(ptr ptrauth (ptr @baz, i32 0))
+  ret i32 2
+}
----------------
oskarwirga wrote:

Thanks for the explanation. I additionally went through each comparison case and commented them out one by one to ensure each failure case was hit. Works like a charm!

https://github.com/llvm/llvm-project/pull/159480


More information about the llvm-commits mailing list