@@ -78,6 +78,80 @@ define ptr @foo() {
7878 ret ptr ptr auth (ptr @g , i32 0 )
7979}
8080
81+ ;--- finalize-isel.ll
82+
83+ ; RUN: llc < finalize-isel.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
84+ ; RUN: -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel | \
85+ ; RUN: FileCheck --check-prefixes=ISEL,ISEL-ELF %s
86+ ; RUN: llc < finalize-isel.ll -mtriple arm64-apple-ios -mattr=+pauth -global-isel=1 \
87+ ; RUN: -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel | \
88+ ; RUN: FileCheck --check-prefixes=ISEL %s
89+
90+ @const_table_local = dso_local constant [3 x ptr ] [ptr null , ptr null , ptr null ]
91+ @const_table_got = constant [3 x ptr ] [ptr null , ptr null , ptr null ]
92+
93+ define void @store_signed_const_local (ptr %dest ) {
94+ ; ISEL-LABEL: name: store_signed_const_local
95+ ; ISEL: body:
96+ ; ISEL: %0:gpr64common = COPY $x0
97+ ; ISEL-NEXT: %10:gpr64common = MOVaddr target-flags(aarch64-page) @const_table_local + 8, target-flags(aarch64-pageoff, aarch64-nc) @const_table_local + 8
98+ ; ISEL-NEXT: %2:gpr64common = PAUTH_BLEND %0, 1234
99+ ; ISEL-NEXT: %4:gpr64 = PACDA %10, %2
100+ ; ISEL-NEXT: %14:gpr64 = COPY %4
101+ ; ISEL-NEXT: STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
102+ ; ISEL-NEXT: RET_ReallyLR
103+ %dest.i = ptrtoint ptr %dest to i64
104+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
105+ %signed.i = call i64 @llvm.ptrauth.sign (i64 ptrtoint (ptr getelementptr ([2 x ptr ], ptr @const_table_local , i32 0 , i32 1 ) to i64 ), i32 2 , i64 %discr )
106+ %signed.ptr = inttoptr i64 %signed.i to ptr
107+ store ptr %signed.ptr , ptr %dest
108+ ret void
109+ }
110+
111+ define void @store_signed_const_got (ptr %dest ) {
112+ ; ISEL-ELF-LABEL: name: store_signed_const_got
113+ ; ISEL-ELF: body:
114+ ; ISEL-ELF: %0:gpr64common = COPY $x0
115+ ; ISEL-ELF-NEXT: %7:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got
116+ ; ISEL-ELF-NEXT: %6:gpr64common = ADDXri %7, 8, 0
117+ ; ISEL-ELF-NEXT: %2:gpr64common = PAUTH_BLEND %0, 1234
118+ ; ISEL-ELF-NEXT: %4:gpr64 = PACDA %6, %2
119+ ; ISEL-ELF-NEXT: %10:gpr64 = COPY %4
120+ ; ISEL-ELF-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
121+ ; ISEL-ELF-NEXT: RET_ReallyLR
122+ %dest.i = ptrtoint ptr %dest to i64
123+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
124+ %signed.i = call i64 @llvm.ptrauth.sign (i64 ptrtoint (ptr getelementptr ([2 x ptr ], ptr @const_table_got , i32 0 , i32 1 ) to i64 ), i32 2 , i64 %discr )
125+ %signed.ptr = inttoptr i64 %signed.i to ptr
126+ store ptr %signed.ptr , ptr %dest
127+ ret void
128+ }
129+
130+ define void @store_signed_arg (ptr %dest , ptr %p ) {
131+ ; ISEL-LABEL: name: store_signed_arg
132+ ; ISEL: body:
133+ ; ISEL: %0:gpr64common = COPY $x0
134+ ; ISEL-NEXT: %1:gpr64common = COPY $x1
135+ ; ISEL-NEXT: %3:gpr64common = PAUTH_BLEND %0, 1234
136+ ; ISEL-NEXT: %6:gpr64common = ADDXri %1, 8, 0
137+ ; Check that no implicit defs are added to PACDA instruction.
138+ ; ISEL-NEXT: %8:gpr64 = PACDA %6, %3{{$}}
139+ ; ISEL-NEXT: %10:gpr64 = COPY %8
140+ ; ISEL-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
141+ ; ISEL-NEXT: RET_ReallyLR
142+ %dest.i = ptrtoint ptr %dest to i64
143+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
144+ %p.offset = getelementptr [2 x ptr ], ptr %p , i32 0 , i32 1
145+ %p.offset.i = ptrtoint ptr %p.offset to i64
146+ %signed.i = call i64 @llvm.ptrauth.sign (i64 %p.offset.i , i32 2 , i64 %discr )
147+ %signed.ptr = inttoptr i64 %signed.i to ptr
148+ store ptr %signed.ptr , ptr %dest
149+ ret void
150+ }
151+
152+ !llvm.module.flags = !{!0 }
153+ !0 = !{i32 8 , !"ptrauth-elf-got" , i32 1 }
154+
81155;--- ok.ll
82156
83157; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
0 commit comments