File: ptrauth-call.ll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (77 lines) | stat: -rw-r--r-- 2,996 bytes parent folder | download
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s

define i32 @test_ptrauth_call_resign(ptr %p) {
; CHECK-LABEL: @test_ptrauth_call_resign(
; CHECK-NEXT:    [[TMP3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 0, i64 1234) ]
; CHECK-NEXT:    ret i32 [[TMP3]]
;
  %tmp0 = ptrtoint ptr %p to i64
  %tmp1 = call i64 @llvm.ptrauth.resign(i64 %tmp0, i32 0, i64 1234, i32 2, i64 5678)
  %tmp2 = inttoptr i64 %tmp1 to ptr
  %tmp3 = call i32 %tmp2() [ "ptrauth"(i32 2, i64 5678) ]
  ret i32 %tmp3
}

define i32 @test_ptrauth_call_resign_blend(ptr %pp) {
; CHECK-LABEL: @test_ptrauth_call_resign_blend(
; CHECK-NEXT:    [[TMP01:%.*]] = load ptr, ptr [[PP:%.*]], align 8
; CHECK-NEXT:    [[TMP6:%.*]] = call i32 [[TMP01]]() [ "ptrauth"(i32 0, i64 1234) ]
; CHECK-NEXT:    ret i32 [[TMP6]]
;
  %tmp0 = load ptr, ptr %pp, align 8
  %tmp1 = ptrtoint ptr %pp to i64
  %tmp2 = ptrtoint ptr %tmp0 to i64
  %tmp3 = call i64 @llvm.ptrauth.blend(i64 %tmp1, i64 5678)
  %tmp4 = call i64 @llvm.ptrauth.resign(i64 %tmp2, i32 0, i64 1234, i32 1, i64 %tmp3)
  %tmp5 = inttoptr i64 %tmp4 to ptr
  %tmp6 = call i32 %tmp5() [ "ptrauth"(i32 1, i64 %tmp3) ]
  ret i32 %tmp6
}

define i32 @test_ptrauth_call_resign_blend_2(ptr %pp) {
; CHECK-LABEL: @test_ptrauth_call_resign_blend_2(
; CHECK-NEXT:    [[TMP01:%.*]] = load ptr, ptr [[PP:%.*]], align 8
; CHECK-NEXT:    [[TMP1:%.*]] = ptrtoint ptr [[PP]] to i64
; CHECK-NEXT:    [[TMP3:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[TMP1]], i64 5678)
; CHECK-NEXT:    [[TMP6:%.*]] = call i32 [[TMP01]]() [ "ptrauth"(i32 1, i64 [[TMP3]]) ]
; CHECK-NEXT:    ret i32 [[TMP6]]
;
  %tmp0 = load ptr, ptr %pp, align 8
  %tmp1 = ptrtoint ptr %pp to i64
  %tmp2 = ptrtoint ptr %tmp0 to i64
  %tmp3 = call i64 @llvm.ptrauth.blend(i64 %tmp1, i64 5678)
  %tmp4 = call i64 @llvm.ptrauth.resign(i64 %tmp2, i32 1, i64 %tmp3, i32 0, i64 1234)
  %tmp5 = inttoptr i64 %tmp4 to ptr
  %tmp6 = call i32 %tmp5() [ "ptrauth"(i32 0, i64 1234) ]
  ret i32 %tmp6
}

define i32 @test_ptrauth_call_auth(ptr %p) {
; CHECK-LABEL: @test_ptrauth_call_auth(
; CHECK-NEXT:    [[TMP3:%.*]] = call i32 [[P:%.*]]() [ "ptrauth"(i32 2, i64 5678) ]
; CHECK-NEXT:    ret i32 [[TMP3]]
;
  %tmp0 = ptrtoint ptr %p to i64
  %tmp1 = call i64 @llvm.ptrauth.auth(i64 %tmp0, i32 2, i64 5678)
  %tmp2 = inttoptr i64 %tmp1 to ptr
  %tmp3 = call i32 %tmp2()
  ret i32 %tmp3
}

define i32 @test_ptrauth_call_sign(ptr %p) {
; CHECK-LABEL: @test_ptrauth_call_sign(
; CHECK-NEXT:    [[TMP3:%.*]] = call i32 [[P:%.*]]()
; CHECK-NEXT:    ret i32 [[TMP3]]
;
  %tmp0 = ptrtoint ptr %p to i64
  %tmp1 = call i64 @llvm.ptrauth.sign(i64 %tmp0, i32 2, i64 5678)
  %tmp2 = inttoptr i64 %tmp1 to ptr
  %tmp3 = call i32 %tmp2() [ "ptrauth"(i32 2, i64 5678) ]
  ret i32 %tmp3
}

declare i64 @llvm.ptrauth.auth(i64, i32, i64)
declare i64 @llvm.ptrauth.sign(i64, i32, i64)
declare i64 @llvm.ptrauth.resign(i64, i32, i64, i32, i64)
declare i64 @llvm.ptrauth.blend(i64, i64)