Skip to content

Commit 16471ce

Browse files
committed
tests for windows 64bit
1 parent fe03a07 commit 16471ce

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit-2.rs

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@ struct Nest {
4141
second: Pair,
4242
}
4343

44-
// #[repr(C)]
45-
// struct A {
46-
// data: [u8; 2],
47-
// }
48-
44+
// test1: array of [16 x i8]
4945
// CHECK-LABEL: test1{{:|\[}}
5046
#[no_mangle]
5147
pub fn test1(a: *const u8) {
@@ -62,9 +58,7 @@ pub fn test1(a: *const u8) {
6258
// missing-NOT: __security_check_cookie
6359
}
6460

65-
// Note: test2
66-
// struct -> flat aggregate -> array
67-
61+
// test3: array [4 x i8]
6862
// CHECK-LABEL: test3{{:|\[}}
6963
#[no_mangle]
7064
pub fn test3(a: *const u8) {
@@ -81,9 +75,7 @@ pub fn test3(a: *const u8) {
8175
// missing-NOT: __security_check_cookie
8276
}
8377

84-
// Note: test4
85-
// struct -> flat aggregate -> array
86-
78+
// test5: no arrays / no nested arrays
8779
// CHECK-LABEL: test5{{:|\[}}
8880
#[no_mangle]
8981
pub fn test5(a: *const u8) {
@@ -97,6 +89,7 @@ pub fn test5(a: *const u8) {
9789
// missing-NOT: __security_check_cookie
9890
}
9991

92+
// test6: Address-of local taken (j = &a)
10093
// CHECK-LABEL: test6{{:|\[}}
10194
#[no_mangle]
10295
pub unsafe extern "C" fn test6() {
@@ -116,6 +109,7 @@ pub unsafe extern "C" fn test6() {
116109
// missing-NOT: __security_check_cookie
117110
}
118111

112+
// test7: PtrToInt Cast
119113
// CHECK-LABEL: test7{{:|\[}}
120114
#[no_mangle]
121115
pub fn test7(a: i32) {
@@ -131,6 +125,7 @@ pub fn test7(a: i32) {
131125
// missing-NOT: __security_check_cookie
132126
}
133127

128+
// test8: Passing addr-of to function call
134129
// CHECK-LABEL: test8{{:|\[}}
135130
#[no_mangle]
136131
pub fn test8(mut b: i32) {
@@ -144,6 +139,7 @@ pub fn test8(mut b: i32) {
144139
// missing-NOT: __security_check_cookie
145140
}
146141

142+
// test9: Addr-of in select instruction
147143
// CHECK-LABEL: test9{{:|\[}}
148144
#[no_mangle]
149145
pub fn test9() {
@@ -164,6 +160,7 @@ pub fn test9() {
164160
// missing-NOT: __security_check_cookie
165161
}
166162

163+
// test10: Addr-of in phi instruction
167164
// CHECK-LABEL: test10{{:|\[}}
168165
#[no_mangle]
169166
pub fn test10() {
@@ -196,6 +193,7 @@ pub fn test10() {
196193
// missing-NOT: __security_check_cookie
197194
}
198195

196+
// test11: Addr-of struct element(GEP followed by store)
199197
// CHECK-LABEL: test11{{:|\[}}
200198
#[no_mangle]
201199
pub fn test11() {
@@ -216,6 +214,7 @@ pub fn test11() {
216214
// missing-NOT: __security_check_cookie
217215
}
218216

217+
// test12: Addr-of struct element, GEP followed by ptrtoint
219218
// CHECK-LABEL: test12{{:|\[}}
220219
#[no_mangle]
221220
pub fn test12() {
@@ -235,6 +234,7 @@ pub fn test12() {
235234
// missing-NOT: __security_check_cookie
236235
}
237236

237+
// test13: Addr-of struct element, GEP followed by callinst
238238
// CHECK-LABEL: test13{{:|\[}}
239239
#[no_mangle]
240240
pub fn test13() {
@@ -252,6 +252,7 @@ pub fn test13() {
252252
// missing-NOT: __security_check_cookie
253253
}
254254

255+
// test14: Addr-of a local, optimized into a GEP (e.g., &a - 12)
255256
// CHECK-LABEL: test14{{:|\[}}
256257
#[no_mangle]
257258
pub fn test14() {
@@ -269,6 +270,8 @@ pub fn test14() {
269270
// missing-NOT: __security_check_cookie
270271
}
271272

273+
// test15: Addr-of a local cast to a ptr of a different type
274+
// (e.g., int a; ... ; ptr b = &a;)
272275
// CHECK-LABEL: test15{{:|\[}}
273276
#[no_mangle]
274277
pub fn test15() {
@@ -289,6 +292,8 @@ pub fn test15() {
289292
// missing-NOT: __security_check_cookie
290293
}
291294

295+
// test16: Addr-of a local cast to a ptr of a different type (optimized)
296+
// (e.g., int a; ... ; ptr b = &a;)
292297
// CHECK-LABEL: test16{{:|\[}}
293298
#[no_mangle]
294299
pub fn test16() {
@@ -303,10 +308,7 @@ pub fn test16() {
303308
// missing-NOT: __security_check_cookie
304309
}
305310

306-
// Note: test17
307-
// Addr-of a vector nested in a struct:
308-
// There is no such type in rustc corresbonding to '%struct.vec = type { <4 x i32> }' in LLVM.
309-
311+
// test18: Addr-of a variable passed into an invoke instruction
310312
// CHECK-LABEL: test18{{:|\[}}
311313
#[no_mangle]
312314
pub unsafe extern "C" fn test18() -> i32 {
@@ -325,9 +327,11 @@ pub unsafe extern "C" fn test18() -> i32 {
325327
// none-NOT: __security_check_cookie
326328
// missing-NOT: __security_check_cookie
327329

328-
// CHECK-DAG: .seh_endprologue
330+
// CHECK-DAG: .seh_endproc
329331
}
330332

333+
// test19: Addr-of a struct element passed into an invoke instruction
334+
// (GEP followed by an invoke)
331335
// CHECK-LABEL: test19{{:|\[}}
332336
#[no_mangle]
333337
pub unsafe extern "C" fn test19() -> i32 {
@@ -346,9 +350,10 @@ pub unsafe extern "C" fn test19() -> i32 {
346350
// none-NOT: __security_check_cookie
347351
// missing-NOT: __security_check_cookie
348352

349-
// CHECK-DAG: .seh_endprologue
353+
// CHECK-DAG: .seh_endproc
350354
}
351355

356+
// test20: Addr-of a pointer
352357
// CHECK-LABEL: test20{{:|\[}}
353358
#[no_mangle]
354359
pub unsafe extern "C" fn test20() {
@@ -368,6 +373,7 @@ pub unsafe extern "C" fn test20() {
368373
// missing-NOT: __security_check_cookie
369374
}
370375

376+
// test21: Addr-of a casted pointer
371377
// CHECK-LABEL: test21{{:|\[}}
372378
#[no_mangle]
373379
pub unsafe extern "C" fn test21() {
@@ -387,16 +393,7 @@ pub unsafe extern "C" fn test21() {
387393
// missing-NOT: __security_check_cookie
388394
}
389395

390-
// Note: test22
391-
// [2 x i8] in struct will be automatically optimized to i16
392-
// and will not trigger the sspstrong
393-
394-
// Note: test23
395-
// [2 x i8] nested in several layers of structs and unions: same as test22
396-
397-
// Note: test24
398-
// Variable sized alloca(VLA): see https://github.com/rust-lang/rfcs/pull/1909
399-
396+
// test25: array of [4 x i32]
400397
// CHECK-LABEL: test25{{:|\[}}
401398
#[no_mangle]
402399
pub unsafe extern "C" fn test25() -> i32 {
@@ -412,6 +409,9 @@ pub unsafe extern "C" fn test25() -> i32 {
412409
// missing-NOT: __security_check_cookie
413410
}
414411

412+
// test26: Nested structure, no arrays, no address-of expressions
413+
// Verify that the resulting gep-of-gep does not incorrectly trigger
414+
// a stack protector
415415
// CHECK-LABEL: test26{{:|\[}}
416416
#[no_mangle]
417417
pub unsafe extern "C" fn test26() {
@@ -426,6 +426,11 @@ pub unsafe extern "C" fn test26() {
426426
// strong-NOT: __security_check_cookie
427427
}
428428

429+
// test27: Address-of a structure taken in a function with a loop where
430+
// the alloca is an incoming value to a PHI node and a use of that PHI
431+
// node is also an incoming value
432+
// Verify that the address-of analysis does not get stuck in infinite
433+
// recursion when chasing the alloca through the PHI nodes
429434
// CHECK-LABEL: test27{{:|\[}}
430435
#[no_mangle]
431436
pub unsafe extern "C" fn test27() -> i32 {

0 commit comments

Comments
 (0)