1 ; RUN: rm -rf %t && split-file %s %t && cd %t
5 ; RUN: llc < ok.ll -mtriple arm64e-apple-darwin \
6 ; RUN: | FileCheck %s --check-prefix=CHECK-MACHO
7 ; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth \
8 ; RUN: | FileCheck %s --check-prefix=CHECK-ELF
10 ; RUN: llc < ok.ll -mtriple arm64e-apple-darwin \
11 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 \
12 ; RUN: | FileCheck %s --check-prefix=CHECK-MACHO
13 ; RUN: llc < ok.ll -mtriple aarch64-elf -mattr=+pauth \
14 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 \
15 ; RUN: | FileCheck %s --check-prefix=CHECK-ELF
17 @g = external global i32
19 @g_weak = extern_weak global i32
21 @g_strong_def = constant i32 42
23 ; CHECK-ELF-LABEL: .globl g.ref.ia.0
24 ; CHECK-ELF-NEXT: .p2align 4
25 ; CHECK-ELF-NEXT: g.ref.ia.0:
26 ; CHECK-ELF-NEXT: .xword 5
27 ; CHECK-ELF-NEXT: .xword g@AUTH(ia,0)
28 ; CHECK-ELF-NEXT: .xword 6
30 ; CHECK-MACHO-LABEL: .section __DATA,__const
31 ; CHECK-MACHO-NEXT: .globl _g.ref.ia.0
32 ; CHECK-MACHO-NEXT: .p2align 4
33 ; CHECK-MACHO-NEXT: _g.ref.ia.0:
34 ; CHECK-MACHO-NEXT: .quad 5
35 ; CHECK-MACHO-NEXT: .quad _g@AUTH(ia,0)
36 ; CHECK-MACHO-NEXT: .quad 6
38 @g.ref.ia.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, i32 0), i64 6 }
40 ; CHECK-ELF-LABEL: .globl g.ref.ia.42
41 ; CHECK-ELF-NEXT: .p2align 3
42 ; CHECK-ELF-NEXT: g.ref.ia.42:
43 ; CHECK-ELF-NEXT: .xword g@AUTH(ia,42)
45 ; CHECK-MACHO-LABEL: .globl _g.ref.ia.42
46 ; CHECK-MACHO-NEXT: .p2align 3
47 ; CHECK-MACHO-NEXT: _g.ref.ia.42:
48 ; CHECK-MACHO-NEXT: .quad _g@AUTH(ia,42)
50 @g.ref.ia.42 = constant ptr ptrauth (ptr @g, i32 0, i64 42)
52 ; CHECK-ELF-LABEL: .globl g.ref.ib.0
53 ; CHECK-ELF-NEXT: .p2align 4
54 ; CHECK-ELF-NEXT: g.ref.ib.0:
55 ; CHECK-ELF-NEXT: .xword 5
56 ; CHECK-ELF-NEXT: .xword g@AUTH(ib,0)
57 ; CHECK-ELF-NEXT: .xword 6
59 ; CHECK-MACHO-LABEL: .globl _g.ref.ib.0
60 ; CHECK-MACHO-NEXT: .p2align 4
61 ; CHECK-MACHO-NEXT: _g.ref.ib.0:
62 ; CHECK-MACHO-NEXT: .quad 5
63 ; CHECK-MACHO-NEXT: .quad _g@AUTH(ib,0)
64 ; CHECK-MACHO-NEXT: .quad 6
66 @g.ref.ib.0 = constant { i64, ptr, i64 } { i64 5, ptr ptrauth (ptr @g, i32 1, i64 0), i64 6 }
68 ; CHECK-ELF-LABEL: .globl g.ref.da.42.addr
69 ; CHECK-ELF-NEXT: .p2align 3
70 ; CHECK-ELF-NEXT: g.ref.da.42.addr:
71 ; CHECK-ELF-NEXT: .xword g@AUTH(da,42,addr)
73 ; CHECK-MACHO-LABEL: .globl _g.ref.da.42.addr
74 ; CHECK-MACHO-NEXT: .p2align 3
75 ; CHECK-MACHO-NEXT: _g.ref.da.42.addr:
76 ; CHECK-MACHO-NEXT: .quad _g@AUTH(da,42,addr)
78 @g.ref.da.42.addr = constant ptr ptrauth (ptr @g, i32 2, i64 42, ptr @g.ref.da.42.addr)
80 ; CHECK-ELF-LABEL: .globl g.offset.ref.da.0
81 ; CHECK-ELF-NEXT: .p2align 3
82 ; CHECK-ELF-NEXT: g.offset.ref.da.0:
83 ; CHECK-ELF-NEXT: .xword (g+16)@AUTH(da,0)
85 ; CHECK-MACHO-LABEL: .globl _g.offset.ref.da.0
86 ; CHECK-MACHO-NEXT: .p2align 3
87 ; CHECK-MACHO-NEXT: _g.offset.ref.da.0:
88 ; CHECK-MACHO-NEXT: .quad (_g+16)@AUTH(da,0)
90 @g.offset.ref.da.0 = constant ptr ptrauth (i8* getelementptr (i8, ptr @g, i64 16), i32 2)
92 ; CHECK-ELF-LABEL: .globl g.big_offset.ref.da.0
93 ; CHECK-ELF-NEXT: .p2align 3
94 ; CHECK-ELF-NEXT: g.big_offset.ref.da.0:
95 ; CHECK-ELF-NEXT: .xword (g+2147549185)@AUTH(da,0)
97 ; CHECK-MACHO-LABEL: .globl _g.big_offset.ref.da.0
98 ; CHECK-MACHO-NEXT: .p2align 3
99 ; CHECK-MACHO-NEXT: _g.big_offset.ref.da.0:
100 ; CHECK-MACHO-NEXT: .quad (_g+2147549185)@AUTH(da,0)
102 @g.big_offset.ref.da.0 = constant ptr ptrauth (i8* getelementptr (i8, ptr @g, i64 add (i64 2147483648, i64 65537)), i32 2)
104 ; CHECK-ELF-LABEL: .globl g.weird_ref.da.0
105 ; CHECK-ELF-NEXT: .p2align 3
106 ; CHECK-ELF-NEXT: g.weird_ref.da.0:
107 ; CHECK-ELF-NEXT: .xword (g+16)@AUTH(da,0)
109 ; CHECK-MACHO-LABEL: .globl _g.weird_ref.da.0
110 ; CHECK-MACHO-NEXT: .p2align 3
111 ; CHECK-MACHO-NEXT: _g.weird_ref.da.0:
112 ; CHECK-MACHO-NEXT: .quad (_g+16)@AUTH(da,0)
114 @g.weird_ref.da.0 = constant i64 ptrtoint (ptr inttoptr (i64 ptrtoint (ptr ptrauth (i8* getelementptr (i8, ptr @g, i64 16), i32 2) to i64) to ptr) to i64)
116 ; CHECK-ELF-LABEL: .globl g_weak.ref.ia.42
117 ; CHECK-ELF-NEXT: .p2align 3
118 ; CHECK-ELF-NEXT: g_weak.ref.ia.42:
119 ; CHECK-ELF-NEXT: .xword g_weak@AUTH(ia,42)
121 ; CHECK-MACHO-LABEL: .globl _g_weak.ref.ia.42
122 ; CHECK-MACHO-NEXT: .p2align 3
123 ; CHECK-MACHO-NEXT: _g_weak.ref.ia.42:
124 ; CHECK-MACHO-NEXT: .quad _g_weak@AUTH(ia,42)
126 @g_weak.ref.ia.42 = constant ptr ptrauth (ptr @g_weak, i32 0, i64 42)
128 ; CHECK-ELF-LABEL: .globl g_strong_def.ref.da.0
129 ; CHECK-ELF-NEXT: .p2align 3
130 ; CHECK-ELF-NEXT: g_strong_def.ref.da.0:
131 ; CHECK-ELF-NEXT: .xword g_strong_def@AUTH(da,0)
133 ; CHECK-MACHO-LABEL: .globl _g_strong_def.ref.da.0
134 ; CHECK-MACHO-NEXT: .p2align 3
135 ; CHECK-MACHO-NEXT: _g_strong_def.ref.da.0:
136 ; CHECK-MACHO-NEXT: .quad _g_strong_def@AUTH(da,0)
138 @g_strong_def.ref.da.0 = constant ptr ptrauth (ptr @g_strong_def, i32 2)
142 ; RUN: not --crash llc < err-key.ll -mtriple arm64e-apple-darwin 2>&1 \
143 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
144 ; RUN: not --crash llc < err-key.ll -mtriple aarch64-elf -mattr=+pauth 2>&1 \
145 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
147 ; RUN: not --crash llc < err-key.ll -mtriple arm64e-apple-darwin \
148 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
149 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
150 ; RUN: not --crash llc < err-key.ll -mtriple aarch64-elf -mattr=+pauth \
151 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
152 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-KEY
154 ; CHECK-ERR-KEY: LLVM ERROR: AArch64 PAC Key ID '4' out of range [0, 3]
156 @g = external global i32
157 @g.ref.4.0 = constant ptr ptrauth (ptr @g, i32 4, i64 0)
161 ; RUN: not --crash llc < err-disc.ll -mtriple arm64e-apple-darwin 2>&1 \
162 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
163 ; RUN: not --crash llc < err-disc.ll -mtriple aarch64-elf -mattr=+pauth 2>&1 \
164 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
166 ; RUN: not --crash llc < err-disc.ll -mtriple arm64e-apple-darwin \
167 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
168 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
169 ; RUN: not --crash llc < err-disc.ll -mtriple aarch64-elf -mattr=+pauth \
170 ; RUN: -global-isel -verify-machineinstrs -global-isel-abort=1 2>&1 \
171 ; RUN: | FileCheck %s --check-prefix=CHECK-ERR-DISC
173 ; CHECK-ERR-DISC: LLVM ERROR: AArch64 PAC Discriminator '65536' out of range [0, 0xFFFF]
175 @g = external global i32
176 @g.ref.ia.65536 = constant ptr ptrauth (ptr @g, i32 0, i64 65536)