|
1 |
| -; RUN: llc -mtriple aarch64-linux-pauthtest -o - %s \ |
| 1 | +; RUN: llc -mtriple aarch64 -o - %s \ |
2 | 2 | ; RUN: -aarch64-authenticated-lr-check-method=xpac-hint \
|
3 | 3 | ; RUN: -stop-before=aarch64-ptrauth \
|
4 | 4 | ; RUN: | FileCheck --check-prefix=MIR %s
|
5 | 5 |
|
6 |
| -; RUN: llc -mtriple aarch64-linux-pauthtest -o - %s \ |
| 6 | +; RUN: llc -mtriple aarch64 -o - %s -asm-verbose=0 \ |
7 | 7 | ; RUN: -aarch64-authenticated-lr-check-method=xpac-hint \
|
8 | 8 | ; RUN: | FileCheck --check-prefix=ASM %s
|
9 | 9 |
|
10 | 10 | 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"
|
11 | 11 |
|
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. |
14 | 14 | define i32 @test_scratch_reg_nobti(ptr %callee, ptr %addr) #0 {
|
15 | 15 | entry:
|
16 |
| - ; Force spilling of LR |
| 16 | + ;; Force spilling of LR |
17 | 17 | 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. |
19 | 20 | tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"()
|
20 | 21 | tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"()
|
21 | 22 | %addr.i = ptrtoint ptr %addr to i64
|
22 | 23 | %call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ]
|
23 | 24 | ret i32 %call
|
24 | 25 | }
|
| 26 | +;; Ensure the specific tail call pseudo instruction is used. |
25 | 27 | ; MIR-LABEL: name: test_scratch_reg_nobti
|
26 | 28 | ; MIR: AUTH_TCRETURN{{ }}
|
27 | 29 | ;
|
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 |
33 | 59 | ; ASM-NEXT: .Lauth_success_0:
|
34 |
| -; ASM-NEXT: braa x0, x16 |
| 60 | +; ASM-NEXT: braa x0, x16 |
| 61 | +; ASM-NEXT: .Lfunc_end0: |
35 | 62 |
|
36 |
| -; The same for AUTH_TCRETURN_BTI. |
| 63 | +;; The same for AUTH_TCRETURN_BTI. |
37 | 64 | define i32 @test_scratch_reg_bti(ptr %callee, ptr %addr) "branch-target-enforcement" #0 {
|
38 | 65 | entry:
|
39 |
| - ; Force spilling of LR |
| 66 | + ;; Force spilling of LR |
40 | 67 | 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. |
42 | 70 | tail call void asm sideeffect "", "~{x0},~{x1},~{x2},~{x3},~{x4},~{x5},~{x6},~{x7},~{x8},~{x9},~{x10},~{x11},~{x12},~{x13},~{x14},~{x15}"()
|
43 | 71 | tail call void asm sideeffect "", "~{x18},~{x19},~{x20},~{x21},~{x22},~{x23},~{x24},~{x25},~{x26},~{x27},~{x28},~{fp}"()
|
44 | 72 | %addr.i = ptrtoint ptr %addr to i64
|
45 | 73 | %call = tail call i32 %callee() #1 [ "ptrauth"(i32 0, i64 %addr.i) ]
|
46 | 74 | ret i32 %call
|
47 | 75 | }
|
| 76 | +;; Ensure the specific tail call pseudo instruction is used. |
48 | 77 | ; MIR-LABEL: name: test_scratch_reg_bti
|
49 | 78 | ; MIR: AUTH_TCRETURN_BTI
|
50 | 79 | ;
|
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 |
56 | 109 | ; ASM-NEXT: .Lauth_success_1:
|
57 |
| -; ASM-NEXT: braa x16, x0 |
| 110 | +; ASM-NEXT: braa x16, x0 |
| 111 | +; ASM-NEXT: .Lfunc_end1: |
58 | 112 |
|
59 | 113 | attributes #0 = { nounwind "ptrauth-auth-traps" "ptrauth-calls" "ptrauth-returns" "target-features"="+pauth" }
|
0 commit comments