@@ -82,26 +82,45 @@ define ptr @foo() {
8282
8383; RUN: llc < finalize-isel.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
8484; RUN: -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel | \
85- ; RUN: FileCheck --check-prefixes=ISEL,ISEL-ELF %s
85+ ; RUN: FileCheck --check-prefixes=ISEL-MIR ,ISEL-MIR -ELF %s
8686; RUN: llc < finalize-isel.ll -mtriple arm64-apple-ios -mattr=+pauth -global-isel=1 \
8787; RUN: -verify-machineinstrs -global-isel-abort=1 -stop-after=finalize-isel | \
88- ; RUN: FileCheck --check-prefixes=ISEL %s
88+ ; RUN: FileCheck --check-prefixes=ISEL-MIR %s
89+ ; RUN: llc < finalize-isel.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
90+ ; RUN: -verify-machineinstrs -global-isel-abort=1 -asm-verbose=0 | \
91+ ; RUN: FileCheck --check-prefixes=ISEL-ASM,ISEL-ASM-ELF %s
92+ ; RUN: llc < finalize-isel.ll -mtriple arm64-apple-ios -mattr=+pauth -global-isel=1 \
93+ ; RUN: -verify-machineinstrs -global-isel-abort=1 -asm-verbose=0 | \
94+ ; RUN: FileCheck --check-prefixes=ISEL-ASM,ISEL-ASM-MACHO %s
8995
9096@const_table_local = dso_local constant [3 x ptr ] [ptr null , ptr null , ptr null ]
9197@const_table_got = constant [3 x ptr ] [ptr null , ptr null , ptr null ]
9298
9399define 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: %15:gpr64noip = COPY %2
100- ; ISEL-NEXT: MOVaddrPAC @const_table_local + 8, 2, %15, 0, implicit-def $x16, implicit-def $x17
101- ; ISEL-NEXT: %4:gpr64 = COPY $x16
102- ; ISEL-NEXT: %14:gpr64 = COPY %4
103- ; ISEL-NEXT: STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
104- ; ISEL-NEXT: RET_ReallyLR
100+ ; ISEL-MIR-LABEL: name: store_signed_const_local
101+ ; ISEL-MIR: body:
102+ ; ISEL-MIR: %0:gpr64common = COPY $x0
103+ ; ISEL-MIR-NEXT: %10:gpr64common = MOVaddr target-flags(aarch64-page) @const_table_local + 8, target-flags(aarch64-pageoff, aarch64-nc) @const_table_local + 8
104+ ; ISEL-MIR-NEXT: %2:gpr64common = PAUTH_BLEND %0, 1234
105+ ; ISEL-MIR-NEXT: %15:gpr64noip = COPY %2
106+ ; ISEL-MIR-NEXT: MOVaddrPAC @const_table_local + 8, 2, %15, 0, implicit-def $x16, implicit-def $x17
107+ ; ISEL-MIR-NEXT: %4:gpr64 = COPY $x16
108+ ; ISEL-MIR-NEXT: %14:gpr64 = COPY %4
109+ ; ISEL-MIR-NEXT: STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
110+ ; ISEL-MIR-NEXT: RET_ReallyLR
111+ ;
112+ ; ISEL-ASM-LABEL: store_signed_const_local:
113+ ; ISEL-ASM-NEXT: .cfi_startproc
114+ ; ISEL-ASM-NEXT: mov x8, x0
115+ ; ISEL-ASM-NEXT: movk x8, #1234, lsl #48
116+ ; ISEL-ASM-ELF-NEXT: adrp x16, const_table_local
117+ ; ISEL-ASM-ELF-NEXT: add x16, x16, :lo12:const_table_local
118+ ; ISEL-ASM-MACHO-NEXT: adrp x16, _const_table_local@PAGE
119+ ; ISEL-ASM-MACHO-NEXT: add x16, x16, _const_table_local@PAGEOFF
120+ ; ISEL-ASM-NEXT: add x16, x16, #8
121+ ; ISEL-ASM-NEXT: pacda x16, x8
122+ ; ISEL-ASM-NEXT: str x16, [x0]
123+ ; ISEL-ASM-NEXT: ret
105124 %dest.i = ptrtoint ptr %dest to i64
106125 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
107126 %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 )
@@ -111,18 +130,37 @@ define void @store_signed_const_local(ptr %dest) {
111130}
112131
113132define void @store_signed_const_got (ptr %dest ) {
114- ; ISEL-ELF-LABEL: name: store_signed_const_got
115- ; ISEL-ELF: body:
116- ; ISEL-ELF: %0:gpr64common = COPY $x0
117- ; ISEL-ELF-NEXT: %7:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got
118- ; ISEL-ELF-NEXT: %6:gpr64common = ADDXri %7, 8, 0
119- ; ISEL-ELF-NEXT: %2:gpr64common = PAUTH_BLEND %0, 1234
120- ; ISEL-ELF-NEXT: %12:gpr64noip = COPY %2
121- ; ISEL-ELF-NEXT: LOADgotPAC target-flags(aarch64-got) @const_table_got + 8, 2, %12, 0, implicit-def $x16, implicit-def $x17, implicit-def $nzcv
122- ; ISEL-ELF-NEXT: %4:gpr64 = COPY $x16
123- ; ISEL-ELF-NEXT: %10:gpr64 = COPY %4
124- ; ISEL-ELF-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
125- ; ISEL-ELF-NEXT: RET_ReallyLR
133+ ; ISEL-MIR-ELF-LABEL: name: store_signed_const_got
134+ ; ISEL-MIR-ELF: body:
135+ ; ISEL-MIR-ELF: %0:gpr64common = COPY $x0
136+ ; ISEL-MIR-ELF-NEXT: %7:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got
137+ ; ISEL-MIR-ELF-NEXT: %6:gpr64common = ADDXri %7, 8, 0
138+ ; ISEL-MIR-ELF-NEXT: %2:gpr64common = PAUTH_BLEND %0, 1234
139+ ; ISEL-MIR-ELF-NEXT: %12:gpr64noip = COPY %2
140+ ; ISEL-MIR-ELF-NEXT: LOADgotPAC target-flags(aarch64-got) @const_table_got + 8, 2, %12, 0, implicit-def $x16, implicit-def $x17, implicit-def $nzcv
141+ ; ISEL-MIR-ELF-NEXT: %4:gpr64 = COPY $x16
142+ ; ISEL-MIR-ELF-NEXT: %10:gpr64 = COPY %4
143+ ; ISEL-MIR-ELF-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
144+ ; ISEL-MIR-ELF-NEXT: RET_ReallyLR
145+ ;
146+ ; ISEL-ASM-ELF-LABEL: store_signed_const_got:
147+ ; ISEL-ASM-ELF-NEXT: .cfi_startproc
148+ ; ISEL-ASM-ELF-NEXT: mov x8, x0
149+ ; ISEL-ASM-ELF-NEXT: movk x8, #1234, lsl #48
150+ ; ISEL-ASM-ELF-NEXT: adrp x17, :got_auth:const_table_got
151+ ; ISEL-ASM-ELF-NEXT: add x17, x17, :got_auth_lo12:const_table_got
152+ ; ISEL-ASM-ELF-NEXT: ldr x16, [x17]
153+ ; ISEL-ASM-ELF-NEXT: autda x16, x17
154+ ; ISEL-ASM-ELF-NEXT: mov x17, x16
155+ ; ISEL-ASM-ELF-NEXT: xpacd x17
156+ ; ISEL-ASM-ELF-NEXT: cmp x16, x17
157+ ; ISEL-ASM-ELF-NEXT: b.eq .Lauth_success_0
158+ ; ISEL-ASM-ELF-NEXT: brk #0xc472
159+ ; ISEL-ASM-ELF-NEXT: .Lauth_success_0:
160+ ; ISEL-ASM-ELF-NEXT: add x16, x16, #8
161+ ; ISEL-ASM-ELF-NEXT: pacda x16, x8
162+ ; ISEL-ASM-ELF-NEXT: str x16, [x0]
163+ ; ISEL-ASM-ELF-NEXT: ret
126164 %dest.i = ptrtoint ptr %dest to i64
127165 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
128166 %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 )
@@ -132,17 +170,26 @@ define void @store_signed_const_got(ptr %dest) {
132170}
133171
134172define void @store_signed_arg (ptr %dest , ptr %p ) {
135- ; ISEL-LABEL: name: store_signed_arg
136- ; ISEL: body:
137- ; ISEL: %0:gpr64common = COPY $x0
138- ; ISEL-NEXT: %1:gpr64common = COPY $x1
139- ; ISEL-NEXT: %3:gpr64common = PAUTH_BLEND %0, 1234
140- ; ISEL-NEXT: %6:gpr64common = ADDXri %1, 8, 0
173+ ; ISEL-MIR- LABEL: name: store_signed_arg
174+ ; ISEL-MIR : body:
175+ ; ISEL-MIR : %0:gpr64common = COPY $x0
176+ ; ISEL-MIR- NEXT: %1:gpr64common = COPY $x1
177+ ; ISEL-MIR- NEXT: %3:gpr64common = PAUTH_BLEND %0, 1234
178+ ; ISEL-MIR- NEXT: %6:gpr64common = ADDXri %1, 8, 0
141179; Check that no implicit defs are added to PACDA instruction.
142- ; ISEL-NEXT: %8:gpr64 = PACDA %6, %3{{$}}
143- ; ISEL-NEXT: %10:gpr64 = COPY %8
144- ; ISEL-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
145- ; ISEL-NEXT: RET_ReallyLR
180+ ; ISEL-MIR-NEXT: %8:gpr64 = PACDA %6, %3{{$}}
181+ ; ISEL-MIR-NEXT: %10:gpr64 = COPY %8
182+ ; ISEL-MIR-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
183+ ; ISEL-MIR-NEXT: RET_ReallyLR
184+ ;
185+ ; ISEL-ASM-LABEL: store_signed_arg:
186+ ; ISEL-ASM-NEXT: .cfi_startproc
187+ ; ISEL-ASM-NEXT: mov x8, x0
188+ ; ISEL-ASM-NEXT: movk x8, #1234, lsl #48
189+ ; ISEL-ASM-NEXT: add x9, x1, #8
190+ ; ISEL-ASM-NEXT: pacda x9, x8
191+ ; ISEL-ASM-NEXT: str x9, [x0]
192+ ; ISEL-ASM-NEXT: ret
146193 %dest.i = ptrtoint ptr %dest to i64
147194 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
148195 %p.offset = getelementptr [2 x ptr ], ptr %p , i32 0 , i32 1
0 commit comments