Skip to content

Commit db6037e

Browse files
committed
Address the review comments
1 parent 1e92b53 commit db6037e

File tree

1 file changed

+75
-21
lines changed

1 file changed

+75
-21
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,113 @@
1-
; RUN: llc -mtriple aarch64-linux-pauthtest -o - %s \
1+
; RUN: llc -mtriple aarch64 -o - %s \
22
; RUN: -aarch64-authenticated-lr-check-method=xpac-hint \
33
; RUN: -stop-before=aarch64-ptrauth \
44
; RUN: | FileCheck --check-prefix=MIR %s
55

6-
; RUN: llc -mtriple aarch64-linux-pauthtest -o - %s \
6+
; RUN: llc -mtriple aarch64 -o - %s -asm-verbose=0 \
77
; RUN: -aarch64-authenticated-lr-check-method=xpac-hint \
88
; RUN: | FileCheck --check-prefix=ASM %s
99

1010
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32"
1111

12-
; Test that expansion of AUTH_TCRETURN does not crash due to unavailability of
13-
; neither x16 nor x17 as a scratch register.
12+
;; Test that expansion of AUTH_TCRETURN does not crash due to unavailability of
13+
;; neither x16 nor x17 as a scratch register.
1414
define i32 @test_scratch_reg_nobti(ptr %callee, ptr %addr) #0 {
1515
entry:
16-
; Force spilling of LR
16+
;; Force spilling of LR
1717
tail call void asm sideeffect "", "~{lr}"()
18-
; Clobber x0-x15 and x18-x29
18+
;; Clobber x0-x15 and x18-x29. This is rather fragile but it was observed to
19+
;; trick regalloc into allocating both x16 and x17 as inputs of AUTH_TCRETURN.
1920
tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"()
2021
tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"()
2122
%addr.i = ptrtoint ptr %addr to i64
2223
%call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ]
2324
ret i32 %call
2425
}
26+
;; Ensure the specific tail call pseudo instruction is used.
2527
; MIR-LABEL: name: test_scratch_reg_nobti
2628
; MIR: AUTH_TCRETURN{{ }}
2729
;
28-
; ASM-LABEL: @test_scratch_reg_nobti
29-
; ASM: autibsp
30-
; ASM-NEXT: eor x17, x30, x30, lsl #1
31-
; ASM-NEXT: tbz x17, #62, .Lauth_success_0
32-
; ASM-NEXT: brk #0xc471
30+
; ASM-LABEL: test_scratch_reg_nobti:
31+
; ASM-NEXT: pacibsp
32+
; ASM-NEXT: sub sp, sp, #112
33+
; ASM-NEXT: stp x29, x30, [sp, #16]
34+
; ASM-NEXT: mov x16, x1
35+
; ASM-NEXT: stp x28, x27, [sp, #32]
36+
; ASM-NEXT: stp x26, x25, [sp, #48]
37+
; ASM-NEXT: stp x24, x23, [sp, #64]
38+
; ASM-NEXT: stp x22, x21, [sp, #80]
39+
; ASM-NEXT: stp x20, x19, [sp, #96]
40+
; ASM-NEXT: str x0, [sp, #8]
41+
; ASM-NEXT: //APP
42+
; ASM-NEXT: //NO_APP
43+
; ASM-NEXT: //APP
44+
; ASM-NEXT: //NO_APP
45+
; ASM-NEXT: //APP
46+
; ASM-NEXT: //NO_APP
47+
; ASM-NEXT: ldr x0, [sp, #8]
48+
; ASM-NEXT: ldp x20, x19, [sp, #96]
49+
; ASM-NEXT: ldp x22, x21, [sp, #80]
50+
; ASM-NEXT: ldp x24, x23, [sp, #64]
51+
; ASM-NEXT: ldp x26, x25, [sp, #48]
52+
; ASM-NEXT: ldp x28, x27, [sp, #32]
53+
; ASM-NEXT: ldp x29, x30, [sp, #16]
54+
; ASM-NEXT: add sp, sp, #112
55+
; ASM-NEXT: autibsp
56+
; ASM-NEXT: eor x17, x30, x30, lsl #1
57+
; ASM-NEXT: tbz x17, #62, .Lauth_success_0
58+
; ASM-NEXT: brk #0xc471
3359
; ASM-NEXT: .Lauth_success_0:
34-
; ASM-NEXT: braa x0, x16
60+
; ASM-NEXT: braa x0, x16
61+
; ASM-NEXT: .Lfunc_end0:
3562

36-
; The same for AUTH_TCRETURN_BTI.
63+
;; The same for AUTH_TCRETURN_BTI.
3764
define i32 @test_scratch_reg_bti(ptr %callee, ptr %addr) "branch-target-enforcement" #0 {
3865
entry:
39-
; Force spilling of LR
66+
;; Force spilling of LR
4067
tail call void asm sideeffect "", "~{lr}"()
41-
; Clobber x0-x15 and x18-x29
68+
;; Clobber x0-x15 and x18-x29. This is rather fragile but it was observed to
69+
;; trick regalloc into allocating both x16 and x17 as inputs of AUTH_TCRETURN_BTI.
4270
tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"()
4371
tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"()
4472
%addr.i = ptrtoint ptr %addr to i64
4573
%call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ]
4674
ret i32 %call
4775
}
76+
;; Ensure the specific tail call pseudo instruction is used.
4877
; MIR-LABEL: name: test_scratch_reg_bti
4978
; MIR: AUTH_TCRETURN_BTI
5079
;
51-
; ASM-LABEL: @test_scratch_reg_bti
52-
; ASM: autibsp
53-
; ASM-NEXT: eor x17, x30, x30, lsl #1
54-
; ASM-NEXT: tbz x17, #62, .Lauth_success_1
55-
; ASM-NEXT: brk #0xc471
80+
; ASM-LABEL: test_scratch_reg_bti:
81+
; ASM-NEXT: pacibsp
82+
; ASM-NEXT: sub sp, sp, #112
83+
; ASM-NEXT: stp x29, x30, [sp, #16]
84+
; ASM-NEXT: mov x16, x0
85+
; ASM-NEXT: stp x28, x27, [sp, #32]
86+
; ASM-NEXT: stp x26, x25, [sp, #48]
87+
; ASM-NEXT: stp x24, x23, [sp, #64]
88+
; ASM-NEXT: stp x22, x21, [sp, #80]
89+
; ASM-NEXT: stp x20, x19, [sp, #96]
90+
; ASM-NEXT: str x1, [sp, #8]
91+
; ASM-NEXT: //APP
92+
; ASM-NEXT: //NO_APP
93+
; ASM-NEXT: //APP
94+
; ASM-NEXT: //NO_APP
95+
; ASM-NEXT: //APP
96+
; ASM-NEXT: //NO_APP
97+
; ASM-NEXT: ldr x0, [sp, #8]
98+
; ASM-NEXT: ldp x20, x19, [sp, #96]
99+
; ASM-NEXT: ldp x22, x21, [sp, #80]
100+
; ASM-NEXT: ldp x24, x23, [sp, #64]
101+
; ASM-NEXT: ldp x26, x25, [sp, #48]
102+
; ASM-NEXT: ldp x28, x27, [sp, #32]
103+
; ASM-NEXT: ldp x29, x30, [sp, #16]
104+
; ASM-NEXT: add sp, sp, #112
105+
; ASM-NEXT: autibsp
106+
; ASM-NEXT: eor x17, x30, x30, lsl #1
107+
; ASM-NEXT: tbz x17, #62, .Lauth_success_1
108+
; ASM-NEXT: brk #0xc471
56109
; ASM-NEXT: .Lauth_success_1:
57-
; ASM-NEXT: braa x16, x0
110+
; ASM-NEXT: braa x16, x0
111+
; ASM-NEXT: .Lfunc_end1:
58112

59113
attributes #0 = { nounwind "ptrauth-auth-traps" "ptrauth-calls" "ptrauth-returns" "target-features"="+pauth" }

0 commit comments

Comments
 (0)