@@ -125,7 +125,7 @@ define void @store_signed_const_got(ptr %dest) {
125125; ISEL-MIR-ELF: body:
126126; ISEL-MIR-ELF: %0:gpr64common = COPY $x0
127127; ISEL-MIR-ELF-NEXT: %1:gpr64noip = MOVKXi %0, 1234, 48
128- ; ISEL-MIR-ELF-NEXT: %2:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got, implicit-def dead $x16, implicit-def dead $x17, implicit-def dead $nzcv
128+ ; ISEL-MIR-ELF-NEXT: %2:gpr64common = LOADgot target-flags(aarch64-got) @const_table_got
129129; ISEL-MIR-ELF-NEXT: %3:gpr64common = ADDXri killed %2, 8, 0
130130; ISEL-MIR-ELF-NEXT: %5:gpr64noip = COPY %0
131131; ISEL-MIR-ELF-NEXT: LOADgotPAC target-flags(aarch64-got) @const_table_got + 8, 2, %5, 1234, implicit-def $x16, implicit-def $x17, implicit-def $nzcv
@@ -135,16 +135,8 @@ define void @store_signed_const_got(ptr %dest) {
135135;
136136; ISEL-ASM-ELF-LABEL: store_signed_const_got:
137137; ISEL-ASM-ELF-NEXT: .cfi_startproc
138- ; ISEL-ASM-ELF-NEXT: adrp x17, :got_auth:const_table_got
139- ; ISEL-ASM-ELF-NEXT: add x17, x17, :got_auth_lo12:const_table_got
140- ; ISEL-ASM-ELF-NEXT: ldr x16, [x17]
141- ; ISEL-ASM-ELF-NEXT: autda x16, x17
142- ; ISEL-ASM-ELF-NEXT: mov x17, x16
143- ; ISEL-ASM-ELF-NEXT: xpacd x17
144- ; ISEL-ASM-ELF-NEXT: cmp x16, x17
145- ; ISEL-ASM-ELF-NEXT: b.eq .Lauth_success_0
146- ; ISEL-ASM-ELF-NEXT: brk #0xc472
147- ; ISEL-ASM-ELF-NEXT: .Lauth_success_0:
138+ ; ISEL-ASM-ELF-NEXT: adrp x16, :got:const_table_got
139+ ; ISEL-ASM-ELF-NEXT: ldr x16, [x16, :got_lo12:const_table_got]
148140; ISEL-ASM-ELF-NEXT: add x16, x16, #8
149141; ISEL-ASM-ELF-NEXT: mov x17, x0
150142; ISEL-ASM-ELF-NEXT: movk x17, #1234, lsl #48
@@ -189,6 +181,57 @@ define void @store_signed_arg(ptr %dest, ptr %p) {
189181 ret void
190182}
191183
184+ ;--- finalize-isel-elf-got.ll
185+
186+ ; RUN: llc < finalize-isel-elf-got.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=0 \
187+ ; RUN: -verify-machineinstrs -stop-after=finalize-isel | FileCheck --check-prefixes=ISEL-ELF-GOT-MIR %s
188+ ; RUN: llc < finalize-isel-elf-got.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=0 \
189+ ; RUN: -verify-machineinstrs -asm-verbose=0 | FileCheck --check-prefixes=ISEL-ELF-GOT-ASM %s
190+
191+ @const_table_got = constant [3 x ptr ] [ptr null , ptr null , ptr null ]
192+
193+ ; Similar to finalize-isel.ll, but tests conversion of LOADgotAUTH to LOADgotPAC.
194+ ; This requires module-level attribute, thus a separate sub-file.
195+
196+ define void @store_signed_const_got (ptr %dest ) {
197+ ; ISEL-ELF-GOT-MIR-LABEL: name: store_signed_const_got
198+ ; ISEL-ELF-GOT-MIR: body:
199+ ; ISEL-ELF-GOT-MIR: %0:gpr64common = COPY $x0
200+ ; ISEL-ELF-GOT-MIR-NEXT: %1:gpr64noip = MOVKXi %0, 1234, 48
201+ ; ISEL-ELF-GOT-MIR-NEXT: %2:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got, implicit-def dead $x16, implicit-def dead $x17, implicit-def dead $nzcv
202+ ; ISEL-ELF-GOT-MIR-NEXT: %3:gpr64common = ADDXri killed %2, 8, 0
203+ ; ISEL-ELF-GOT-MIR-NEXT: %5:gpr64noip = COPY %0
204+ ; ISEL-ELF-GOT-MIR-NEXT: LOADgotPAC target-flags(aarch64-got) @const_table_got + 8, 2, %5, 1234, implicit-def $x16, implicit-def $x17, implicit-def $nzcv
205+ ; ISEL-ELF-GOT-MIR-NEXT: %4:gpr64 = COPY $x16
206+ ; ISEL-ELF-GOT-MIR-NEXT: STRXui killed %4, %0, 0 :: (store (s64) into %ir.dest)
207+ ; ISEL-ELF-GOT-MIR-NEXT: RET_ReallyLR
208+ ;
209+ ; ISEL-ELF-GOT-ASM-LABEL: store_signed_const_got:
210+ ; ISEL-ELF-GOT-ASM-NEXT: .cfi_startproc
211+ ; ISEL-ELF-GOT-ASM-NEXT: adrp x17, :got_auth:const_table_got
212+ ; ISEL-ELF-GOT-ASM-NEXT: add x17, x17, :got_auth_lo12:const_table_got
213+ ; ISEL-ELF-GOT-ASM-NEXT: ldr x16, [x17]
214+ ; ISEL-ELF-GOT-ASM-NEXT: autda x16, x17
215+ ; ISEL-ELF-GOT-ASM-NEXT: mov x17, x16
216+ ; ISEL-ELF-GOT-ASM-NEXT: xpacd x17
217+ ; ISEL-ELF-GOT-ASM-NEXT: cmp x16, x17
218+ ; ISEL-ELF-GOT-ASM-NEXT: b.eq .Lauth_success_0
219+ ; ISEL-ELF-GOT-ASM-NEXT: brk #0xc472
220+ ; ISEL-ELF-GOT-ASM-NEXT: .Lauth_success_0:
221+ ; ISEL-ELF-GOT-ASM-NEXT: add x16, x16, #8
222+ ; ISEL-ELF-GOT-ASM-NEXT: mov x17, x0
223+ ; ISEL-ELF-GOT-ASM-NEXT: movk x17, #1234, lsl #48
224+ ; ISEL-ELF-GOT-ASM-NEXT: pacda x16, x17
225+ ; ISEL-ELF-GOT-ASM-NEXT: str x16, [x0]
226+ ; ISEL-ELF-GOT-ASM-NEXT: ret
227+ %dest.i = ptrtoint ptr %dest to i64
228+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
229+ %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 )
230+ %signed.ptr = inttoptr i64 %signed.i to ptr
231+ store ptr %signed.ptr , ptr %dest
232+ ret void
233+ }
234+
192235!llvm.module.flags = !{!0 }
193236!0 = !{i32 8 , !"ptrauth-elf-got" , i32 1 }
194237
0 commit comments