File: ptrauth-call.ll

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (77 lines) | stat: -rw-r--r-- 2,996 bytes parent folder | download | duplicates (2)
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)