1 # RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \
2 # RUN: -start-before aarch64-sls-hardening -o - %s \
3 # RUN: -mattr=+pauth,+harden-sls-retbr \
4 # RUN: | FileCheck %s --check-prefixes=CHECK,ISBDSB
5 # RUN: llc -verify-machineinstrs -mtriple=aarch64-none-linux-gnu \
6 # RUN: -start-before aarch64-sls-hardening -o - %s \
7 # RUN: -mattr=+pauth,+harden-sls-retbr -mattr=+sb \
8 # RUN: | FileCheck %s --check-prefixes=CHECK,SB
10 # Check that the SLS hardening pass also protects BRA* indirect branches that
11 # llvm currently does not generate.
13 @ptr_aa = private unnamed_addr constant [2 x ptr] [ptr blockaddress(@br_aa, %return), ptr blockaddress(@br_aa, %l2)], align 8
14 @ptr_aaz = private unnamed_addr constant [2 x ptr] [ptr blockaddress(@br_aaz, %return), ptr blockaddress(@br_aaz, %l2)], align 8
15 @ptr_ab = private unnamed_addr constant [2 x ptr] [ptr blockaddress(@br_ab, %return), ptr blockaddress(@br_ab, %l2)], align 8
16 @ptr_abz = private unnamed_addr constant [2 x ptr] [ptr blockaddress(@br_abz, %return), ptr blockaddress(@br_abz, %l2)], align 8
18 define dso_local i32 @br_aa(i32 %a, i32 %b, i32 %i) {
26 define dso_local i32 @br_aaz(i32 %a, i32 %b, i32 %i) {
34 define dso_local i32 @br_ab(i32 %a, i32 %b, i32 %i) {
42 define dso_local i32 @br_abz(i32 %a, i32 %b, i32 %i) {
53 tracksRegLiveness: true
57 successors: %bb.2, %bb.1
59 $x8 = ADRP target-flags(aarch64-page) @ptr_aa
60 renamable $x8 = ADDXri $x8, target-flags(aarch64-pageoff, aarch64-nc) @ptr_aa, 0
61 renamable $x8 = LDRXroW killed renamable $x8, killed renamable $w2, 1, 1
62 BRAA killed renamable $x8, $sp
68 bb.1.l2 (ir-block-address-taken %ir-block.l2):
69 renamable $w0 = MOVZWi 1, 0
70 RET undef $lr, implicit $w0
72 bb.2.return (ir-block-address-taken %ir-block.return):
73 $w0 = ORRWrs $wzr, $wzr, 0
74 RET undef $lr, implicit $w0
78 tracksRegLiveness: true
80 ; CHECK-LABEL: br_aaz:
82 successors: %bb.2, %bb.1
84 $x8 = ADRP target-flags(aarch64-page) @ptr_aaz
85 renamable $x8 = ADDXri $x8, target-flags(aarch64-pageoff, aarch64-nc) @ptr_aaz, 0
86 renamable $x8 = LDRXroW killed renamable $x8, killed renamable $w2, 1, 1
87 BRAAZ killed renamable $x8
93 bb.1.l2 (ir-block-address-taken %ir-block.l2):
94 renamable $w0 = MOVZWi 1, 0
95 RET undef $lr, implicit $w0
97 bb.2.return (ir-block-address-taken %ir-block.return):
98 $w0 = ORRWrs $wzr, $wzr, 0
99 RET undef $lr, implicit $w0
103 tracksRegLiveness: true
105 ; CHECK-LABEL: br_ab:
107 successors: %bb.2, %bb.1
109 $x8 = ADRP target-flags(aarch64-page) @ptr_ab
110 renamable $x8 = ADDXri $x8, target-flags(aarch64-pageoff, aarch64-nc) @ptr_ab, 0
111 renamable $x8 = LDRXroW killed renamable $x8, killed renamable $w2, 1, 1
112 BRAA killed renamable $x8, $sp
114 ; ISBDSB-NEXT: dsb sy
118 bb.1.l2 (ir-block-address-taken %ir-block.l2):
119 renamable $w0 = MOVZWi 1, 0
120 RET undef $lr, implicit $w0
122 bb.2.return (ir-block-address-taken %ir-block.return):
123 $w0 = ORRWrs $wzr, $wzr, 0
124 RET undef $lr, implicit $w0
128 tracksRegLiveness: true
130 ; CHECK-LABEL: br_abz:
132 successors: %bb.2, %bb.1
134 $x8 = ADRP target-flags(aarch64-page) @ptr_abz
135 renamable $x8 = ADDXri $x8, target-flags(aarch64-pageoff, aarch64-nc) @ptr_abz, 0
136 renamable $x8 = LDRXroW killed renamable $x8, killed renamable $w2, 1, 1
137 BRAAZ killed renamable $x8
139 ; ISBDSB-NEXT: dsb sy
143 bb.1.l2 (ir-block-address-taken %ir-block.l2):
144 renamable $w0 = MOVZWi 1, 0
145 RET undef $lr, implicit $w0
147 bb.2.return (ir-block-address-taken %ir-block.return):
148 $w0 = ORRWrs $wzr, $wzr, 0
149 RET undef $lr, implicit $w0