@@ -12,6 +12,26 @@ define i64 @test_ptrauth_nop(ptr %p) {
12
12
ret i64 %authed
13
13
}
14
14
15
+ declare void @foo ()
16
+
17
+ define i64 @test_ptrauth_nop_constant () {
18
+ ; CHECK-LABEL: @test_ptrauth_nop_constant(
19
+ ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64)
20
+ ;
21
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 ) to i64 ), i32 1 , i64 1234 )
22
+ ret i64 %authed
23
+ }
24
+
25
+ define i64 @test_ptrauth_nop_constant_addrdisc () {
26
+ ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc(
27
+ ; CHECK-NEXT: ret i64 ptrtoint (ptr @foo to i64)
28
+ ;
29
+ %addr = ptrtoint void ()* @foo to i64
30
+ %blended = call i64 @llvm.ptrauth.blend (i64 %addr , i64 1234 )
31
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 , ptr @foo ) to i64 ), i32 1 , i64 %blended )
32
+ ret i64 %authed
33
+ }
34
+
15
35
define i64 @test_ptrauth_nop_mismatch (ptr %p ) {
16
36
; CHECK-LABEL: @test_ptrauth_nop_mismatch(
17
37
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[P:%.*]] to i64
@@ -87,6 +107,59 @@ define i64 @test_ptrauth_resign_auth_mismatch(ptr %p) {
87
107
ret i64 %authed
88
108
}
89
109
110
+ define i64 @test_ptrauth_nop_constant_mismatch () {
111
+ ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch(
112
+ ; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 1, i64 12)
113
+ ; CHECK-NEXT: ret i64 [[AUTHED]]
114
+ ;
115
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 ) to i64 ), i32 1 , i64 12 )
116
+ ret i64 %authed
117
+ }
118
+
119
+ define i64 @test_ptrauth_nop_constant_mismatch_key () {
120
+ ; CHECK-LABEL: @test_ptrauth_nop_constant_mismatch_key(
121
+ ; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234) to i64), i32 0, i64 1234)
122
+ ; CHECK-NEXT: ret i64 [[AUTHED]]
123
+ ;
124
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 ) to i64 ), i32 0 , i64 1234 )
125
+ ret i64 %authed
126
+ }
127
+
128
+ define i64 @test_ptrauth_nop_constant_addrdisc_mismatch () {
129
+ ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch(
130
+ ; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @foo to i64), i64 12)
131
+ ; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]])
132
+ ; CHECK-NEXT: ret i64 [[AUTHED]]
133
+ ;
134
+ %addr = ptrtoint ptr @foo to i64
135
+ %blended = call i64 @llvm.ptrauth.blend (i64 %addr , i64 12 )
136
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 , ptr @foo ) to i64 ), i32 1 , i64 %blended )
137
+ ret i64 %authed
138
+ }
139
+
140
+ define i64 @test_ptrauth_nop_constant_addrdisc_mismatch2 () {
141
+ ; CHECK-LABEL: @test_ptrauth_nop_constant_addrdisc_mismatch2(
142
+ ; CHECK-NEXT: [[BLENDED:%.*]] = call i64 @llvm.ptrauth.blend(i64 ptrtoint (ptr @test_ptrauth_nop to i64), i64 1234)
143
+ ; CHECK-NEXT: [[AUTHED:%.*]] = call i64 @llvm.ptrauth.auth(i64 ptrtoint (ptr ptrauth (ptr @foo, i32 1, i64 1234, ptr @foo) to i64), i32 1, i64 [[BLENDED]])
144
+ ; CHECK-NEXT: ret i64 [[AUTHED]]
145
+ ;
146
+ %addr = ptrtoint ptr @test_ptrauth_nop to i64
147
+ %blended = call i64 @llvm.ptrauth.blend (i64 %addr , i64 1234 )
148
+ %authed = call i64 @llvm.ptrauth.auth (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 , ptr @foo ) to i64 ), i32 1 , i64 %blended )
149
+ ret i64 %authed
150
+ }
151
+
152
+ define i64 @test_ptrauth_resign_ptrauth_constant (ptr %p ) {
153
+ ; CHECK-LABEL: @test_ptrauth_resign_ptrauth_constant(
154
+ ; CHECK-NEXT: ret i64 ptrtoint (ptr ptrauth (ptr @foo, i32 0, i64 42) to i64)
155
+ ;
156
+
157
+ %tmp0 = ptrtoint ptr %p to i64
158
+ %authed = call i64 @llvm.ptrauth.resign (i64 ptrtoint (ptr ptr auth(ptr @foo , i32 1 , i64 1234 ) to i64 ), i32 1 , i64 1234 , i32 0 , i64 42 )
159
+ ret i64 %authed
160
+ }
161
+
90
162
declare i64 @llvm.ptrauth.auth (i64 , i32 , i64 )
91
163
declare i64 @llvm.ptrauth.sign (i64 , i32 , i64 )
92
164
declare i64 @llvm.ptrauth.resign (i64 , i32 , i64 , i32 , i64 )
165
+ declare i64 @llvm.ptrauth.blend (i64 , i64 )
0 commit comments