@@ -82,25 +82,50 @@ 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
99+ ; Test that after post-processing in finalize-isel, MOVaddrPAC (or LOADgotPAC,
100+ ; respectively) has both $AddrDisc and $Disc operands set. MOVaddr (or LOADgotAUTH,
101+ ; respectively) and MOVKXi are not used anymore and are dead-code-eliminated
102+ ; by the later passes.
103+
93104define 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:gpr64noip = MOVKXi %0, 1234
99- ; ISEL-NEXT: %15:gpr64noip = COPY %0
100- ; ISEL-NEXT: %4:gpr64 = PAC %10, 2, 1234, %15, implicit-def dead $x16, implicit-def dead $x17
101- ; ISEL-NEXT: %14:gpr64 = COPY %4
102- ; ISEL-NEXT: STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
103- ; ISEL-NEXT: RET_ReallyLR
105+ ; ISEL-MIR-LABEL: name: store_signed_const_local
106+ ; ISEL-MIR: body:
107+ ; ISEL-MIR: %0:gpr64common = COPY $x0
108+ ; ISEL-MIR-NEXT: %10:gpr64common = MOVaddr target-flags(aarch64-page) @const_table_local + 8, target-flags(aarch64-pageoff, aarch64-nc) @const_table_local + 8
109+ ; ISEL-MIR-NEXT: %2:gpr64noip = MOVKXi %0, 1234, 48
110+ ; ISEL-MIR-NEXT: %15:gpr64noip = COPY %0
111+ ; ISEL-MIR-NEXT: MOVaddrPAC @const_table_local + 8, 2, %15, 1234, implicit-def $x16, implicit-def $x17
112+ ; ISEL-MIR-NEXT: %4:gpr64 = COPY $x16
113+ ; ISEL-MIR-NEXT: %14:gpr64 = COPY %4
114+ ; ISEL-MIR-NEXT: STRXui %14, %0, 0 :: (store (p0) into %ir.dest)
115+ ; ISEL-MIR-NEXT: RET_ReallyLR
116+ ;
117+ ; ISEL-ASM-LABEL: store_signed_const_local:
118+ ; ISEL-ASM-NEXT: .cfi_startproc
119+ ; ISEL-ASM-ELF-NEXT: adrp x16, const_table_local
120+ ; ISEL-ASM-ELF-NEXT: add x16, x16, :lo12:const_table_local
121+ ; ISEL-ASM-MACHO-NEXT: adrp x16, _const_table_local@PAGE
122+ ; ISEL-ASM-MACHO-NEXT: add x16, x16, _const_table_local@PAGEOFF
123+ ; ISEL-ASM-NEXT: add x16, x16, #8
124+ ; ISEL-ASM-NEXT: mov x17, x0
125+ ; ISEL-ASM-NEXT: movk x17, #1234, lsl #48
126+ ; ISEL-ASM-NEXT: pacda x16, x17
127+ ; ISEL-ASM-NEXT: str x16, [x0]
128+ ; ISEL-ASM-NEXT: ret
104129 %dest.i = ptrtoint ptr %dest to i64
105130 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
106131 %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 )
@@ -110,17 +135,37 @@ define void @store_signed_const_local(ptr %dest) {
110135}
111136
112137define void @store_signed_const_got (ptr %dest ) {
113- ; ISEL-ELF-LABEL: name: store_signed_const_got
114- ; ISEL-ELF: body:
115- ; ISEL-ELF: %0:gpr64common = COPY $x0
116- ; ISEL-ELF-NEXT: %7:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got
117- ; ISEL-ELF-NEXT: %6:gpr64common = ADDXri %7, 8, 0
118- ; ISEL-ELF-NEXT: %2:gpr64noip = MOVKXi %0, 1234
119- ; ISEL-ELF-NEXT: %12:gpr64noip = COPY %0
120- ; ISEL-ELF-NEXT: %4:gpr64 = PAC %6, 2, 1234, %12, implicit-def dead $x16, implicit-def dead $x17
121- ; ISEL-ELF-NEXT: %10:gpr64 = COPY %4
122- ; ISEL-ELF-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
123- ; ISEL-ELF-NEXT: RET_ReallyLR
138+ ; ISEL-MIR-ELF-LABEL: name: store_signed_const_got
139+ ; ISEL-MIR-ELF: body:
140+ ; ISEL-MIR-ELF: %0:gpr64common = COPY $x0
141+ ; ISEL-MIR-ELF-NEXT: %7:gpr64common = LOADgotAUTH target-flags(aarch64-got) @const_table_got
142+ ; ISEL-MIR-ELF-NEXT: %6:gpr64common = ADDXri %7, 8, 0
143+ ; ISEL-MIR-ELF-NEXT: %2:gpr64noip = MOVKXi %0, 1234, 48
144+ ; ISEL-MIR-ELF-NEXT: %12:gpr64noip = COPY %0
145+ ; ISEL-MIR-ELF-NEXT: LOADgotPAC target-flags(aarch64-got) @const_table_got + 8, 2, %12, 1234, implicit-def $x16, implicit-def $x17, implicit-def $nzcv
146+ ; ISEL-MIR-ELF-NEXT: %4:gpr64 = COPY $x16
147+ ; ISEL-MIR-ELF-NEXT: %10:gpr64 = COPY %4
148+ ; ISEL-MIR-ELF-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
149+ ; ISEL-MIR-ELF-NEXT: RET_ReallyLR
150+ ;
151+ ; ISEL-ASM-ELF-LABEL: store_signed_const_got:
152+ ; ISEL-ASM-ELF-NEXT: .cfi_startproc
153+ ; ISEL-ASM-ELF-NEXT: adrp x17, :got_auth:const_table_got
154+ ; ISEL-ASM-ELF-NEXT: add x17, x17, :got_auth_lo12:const_table_got
155+ ; ISEL-ASM-ELF-NEXT: ldr x16, [x17]
156+ ; ISEL-ASM-ELF-NEXT: autda x16, x17
157+ ; ISEL-ASM-ELF-NEXT: mov x17, x16
158+ ; ISEL-ASM-ELF-NEXT: xpacd x17
159+ ; ISEL-ASM-ELF-NEXT: cmp x16, x17
160+ ; ISEL-ASM-ELF-NEXT: b.eq .Lauth_success_0
161+ ; ISEL-ASM-ELF-NEXT: brk #0xc472
162+ ; ISEL-ASM-ELF-NEXT: .Lauth_success_0:
163+ ; ISEL-ASM-ELF-NEXT: add x16, x16, #8
164+ ; ISEL-ASM-ELF-NEXT: mov x17, x0
165+ ; ISEL-ASM-ELF-NEXT: movk x17, #1234, lsl #48
166+ ; ISEL-ASM-ELF-NEXT: pacda x16, x17
167+ ; ISEL-ASM-ELF-NEXT: str x16, [x0]
168+ ; ISEL-ASM-ELF-NEXT: ret
124169 %dest.i = ptrtoint ptr %dest to i64
125170 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
126171 %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 )
@@ -130,17 +175,26 @@ define void @store_signed_const_got(ptr %dest) {
130175}
131176
132177define void @store_signed_arg (ptr %dest , ptr %p ) {
133- ; ISEL-LABEL: name: store_signed_arg
134- ; ISEL: body:
135- ; ISEL: %0:gpr64common = COPY $x0
136- ; ISEL-NEXT: %1:gpr64common = COPY $x1
137- ; ISEL-NEXT: %3:gpr64noip = MOVKXi %0, 1234
138- ; ISEL-NEXT: %6:gpr64common = ADDXri %1, 8, 0
139- ; ISEL-NEXT: %12:gpr64noip = COPY %0
140- ; ISEL-NEXT: %8:gpr64 = PAC %6, 2, 1234, %12, implicit-def dead $x16, implicit-def dead $x17
141- ; ISEL-NEXT: %10:gpr64 = COPY %8
142- ; ISEL-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
143- ; ISEL-NEXT: RET_ReallyLR
178+ ; ISEL-MIR-LABEL: name: store_signed_arg
179+ ; ISEL-MIR: body:
180+ ; ISEL-MIR: %0:gpr64common = COPY $x0
181+ ; ISEL-MIR-NEXT: %1:gpr64common = COPY $x1
182+ ; ISEL-MIR-NEXT: %3:gpr64noip = MOVKXi %0, 1234, 48
183+ ; ISEL-MIR-NEXT: %6:gpr64common = ADDXri %1, 8, 0
184+ ; ISEL-MIR-NEXT: %12:gpr64noip = COPY %0
185+ ; ISEL-MIR-NEXT: %8:gpr64 = PAC %6, 2, 1234, %12, implicit-def dead $x16, implicit-def dead $x17
186+ ; ISEL-MIR-NEXT: %10:gpr64 = COPY %8
187+ ; ISEL-MIR-NEXT: STRXui %10, %0, 0 :: (store (p0) into %ir.dest)
188+ ; ISEL-MIR-NEXT: RET_ReallyLR
189+ ;
190+ ; ISEL-ASM-LABEL: store_signed_arg:
191+ ; ISEL-ASM-NEXT: .cfi_startproc
192+ ; ISEL-ASM-NEXT: add x8, x1, #8
193+ ; ISEL-ASM-NEXT: mov x16, x0
194+ ; ISEL-ASM-NEXT: movk x16, #1234, lsl #48
195+ ; ISEL-ASM-NEXT: pacda x8, x16
196+ ; ISEL-ASM-NEXT: str x8, [x0]
197+ ; ISEL-ASM-NEXT: ret
144198 %dest.i = ptrtoint ptr %dest to i64
145199 %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
146200 %p.offset = getelementptr [2 x ptr ], ptr %p , i32 0 , i32 1
0 commit comments