Skip to content

The intrinsic @llvm.ptrauth.resign.load.relative is not recognized by an upstream llvm, while it is recognized by Xcode 26's clang #156947

@gitevedev

Description

@gitevedev

Consider the following IR:

declare i64 @llvm.ptrauth.resign.load.relative(i64, i32 immarg, i64, i32 immarg, i64, i64 immarg)

define i64 @test_resign(i64 %ptr) {
entry:
  ; Just call the intrinsic with some dummy arguments
  %res = call i64 @llvm.ptrauth.resign.load.relative(
      i64 %ptr, 
      i32 0, 
      i64 42, 
      i32 0, 
      i64 42, 
      i64 0
  )
  ret i64 %res
}

When it is compiled using Xcode 26.0's clang

clang -S -target arm64e-apple-macosx26.0 test.ll -o test.s

I am getting a correct assembly output with the pointer signing instructions:

.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 11, 0
	.globl	_test_resign                    ; -- Begin function test_resign
	.p2align	2
_test_resign:                           ; @test_resign
	.cfi_startproc
; %bb.0:                                ; %entry
	mov	x16, x0
	mov	x17, #42                        ; =0x2a
	autia	x16, x17
	mov	x17, x16
	xpaci	x17
	cmp	x16, x17
	b.eq	Lauth_success_0
	mov	x16, x17
	b	Lresign_end_0
Lauth_success_0:
	ldrsw	x17, [x16, #0]!
	add	x16, x16, x17
	mov	x17, #42                        ; =0x2a
	pacia	x16, x17
Lresign_end_0:
	mov	x0, x16
	ret
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols

However when using the upstream llvm, the intrinsic is not recognized and considered to be a function call:

.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 26, 0
	.globl	_test_resign                    ; -- Begin function test_resign
	.p2align	2
_test_resign:                           ; @test_resign
	.cfi_startproc
; %bb.0:                                ; %entry
	stp	x29, x30, [sp, #-16]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	mov	w1, #0                          ; =0x0
	mov	w2, #42                         ; =0x2a
	mov	w3, #0                          ; =0x0
	mov	w4, #42                         ; =0x2a
	mov	x5, #0                          ; =0x0
	bl	_llvm.ptrauth.resign.load.relative
	ldp	x29, x30, [sp], #16             ; 16-byte Folded Reload
	ret
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols

tried various branches (main, stable/20240723 (this is supposedly the one used by Xcode 26.0))

cc @ojhunt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions