@@ -78,6 +78,82 @@ 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: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
104+ %dest.i = ptrtoint ptr %dest to i64
105+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
106+ %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 )
107+ %signed.ptr = inttoptr i64 %signed.i to ptr
108+ store ptr %signed.ptr , ptr %dest
109+ ret void
110+ }
111+
112+ define 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
124+ %dest.i = ptrtoint ptr %dest to i64
125+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
126+ %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 )
127+ %signed.ptr = inttoptr i64 %signed.i to ptr
128+ store ptr %signed.ptr , ptr %dest
129+ ret void
130+ }
131+
132+ define 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
144+ %dest.i = ptrtoint ptr %dest to i64
145+ %discr = call i64 @llvm.ptrauth.blend (i64 %dest.i , i64 1234 )
146+ %p.offset = getelementptr [2 x ptr ], ptr %p , i32 0 , i32 1
147+ %p.offset.i = ptrtoint ptr %p.offset to i64
148+ %signed.i = call i64 @llvm.ptrauth.sign (i64 %p.offset.i , i32 2 , i64 %discr )
149+ %signed.ptr = inttoptr i64 %signed.i to ptr
150+ store ptr %signed.ptr , ptr %dest
151+ ret void
152+ }
153+
154+ !llvm.module.flags = !{!0 }
155+ !0 = !{i32 8 , !"ptrauth-elf-got" , i32 1 }
156+
81157;--- ok.ll
82158
83159; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth -global-isel=1 \
0 commit comments