File: ptrauth-ret-trap.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (98 lines) | stat: -rw-r--r-- 3,070 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
; RUN: llc -mtriple aarch64-linux-gnu -mattr=+pauth -asm-verbose=false -disable-post-ra -o - %s | FileCheck %s

; CHECK-LABEL:  test_tailcall:
; CHECK-NEXT:   pacibsp
; CHECK-NEXT:   str x30, [sp, #-16]!
; CHECK-NEXT:   bl bar
; CHECK-NEXT:   ldr x30, [sp], #16
; CHECK-NEXT:   autibsp
; CHECK-NEXT:   eor x16, x30, x30, lsl #1
; CHECK-NEXT:   tbnz x16, #62, [[BAD:.L.*]]
; CHECK-NEXT:   b bar
; CHECK-NEXT:   [[BAD]]:
; CHECK-NEXT:   brk #0xc471
define i32 @test_tailcall() #0 {
  call i32 @bar()
  %c = tail call i32 @bar()
  ret i32 %c
}

; CHECK-LABEL: test_tailcall_noframe:
; CHECK-NEXT:  b bar
define i32 @test_tailcall_noframe() #0 {
  %c = tail call i32 @bar()
  ret i32 %c
}

; CHECK-LABEL: test_tailcall_indirect:
; CHECK:         autibsp
; CHECK:         eor     x16, x30, x30, lsl #1
; CHECK:         tbnz    x16, #62, [[BAD:.L.*]]
; CHECK:         br      x0
; CHECK: [[BAD]]:
; CHECK:         brk     #0xc471
define void @test_tailcall_indirect(ptr %fptr) #0 {
  call i32 @test_tailcall()
  tail call void %fptr()
  ret void
}

; CHECK-LABEL: test_tailcall_indirect_in_x9:
; CHECK:         autibsp
; CHECK:         eor     x16, x30, x30, lsl #1
; CHECK:         tbnz    x16, #62, [[BAD:.L.*]]
; CHECK:         br      x9
; CHECK: [[BAD]]:
; CHECK:         brk     #0xc471
define void @test_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 {
  %ptr = alloca i8, i32 16
  call i32 @test_tailcall()
  tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in)
  ret void
}

; CHECK-LABEL: test_auth_tailcall_indirect:
; CHECK:         autibsp
; CHECK:         eor     x16, x30, x30, lsl #1
; CHECK:         tbnz    x16, #62, [[BAD:.L.*]]
; CHECK:         mov x16, #42
; CHECK:         braa      x0, x16
; CHECK: [[BAD]]:
; CHECK:         brk     #0xc471
define void @test_auth_tailcall_indirect(ptr %fptr) #0 {
  call i32 @test_tailcall()
  tail call void %fptr() [ "ptrauth"(i32 0, i64 42) ]
  ret void
}

; CHECK-LABEL: test_auth_tailcall_indirect_in_x9:
; CHECK:         autibsp
; CHECK:         eor     x16, x30, x30, lsl #1
; CHECK:         tbnz    x16, #62, [[BAD:.L.*]]
; CHECK:         brabz      x9
; CHECK: [[BAD]]:
; CHECK:         brk     #0xc471
define void @test_auth_tailcall_indirect_in_x9(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 {
  %ptr = alloca i8, i32 16
  call i32 @test_tailcall()
  tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i32 1, i64 0) ]
  ret void
}

; CHECK-LABEL: test_auth_tailcall_indirect_bti:
; CHECK:         autibsp
; CHECK:         eor     x17, x30, x30, lsl #1
; CHECK:         tbnz    x17, #62, [[BAD:.L.*]]
; CHECK:         brabz      x16
; CHECK: [[BAD]]:
; CHECK:         brk     #0xc471
define void @test_auth_tailcall_indirect_bti(ptr sret(i64) %ret, [8 x i64] %in, ptr %fptr) #0 "branch-target-enforcement"="true" {
  %ptr = alloca i8, i32 16
  call i32 @test_tailcall()
  tail call void %fptr(ptr sret(i64) %ret, [8 x i64] %in) [ "ptrauth"(i32 1, i64 0) ]
  ret void
}

declare i32 @bar()

attributes #0 = { nounwind "ptrauth-returns" "ptrauth-auth-traps" }