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