]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/sanitizer-recover.rs
Rollup merge of #66763 - Parth:patch-2, r=steveklabnik
[rust.git] / src / test / codegen / sanitizer-recover.rs
1 // Verifies that AddressSanitizer and MemorySanitizer
2 // recovery mode can be enabled with -Zsanitizer-recover.
3 //
4 // needs-sanitizer-support
5 // only-linux
6 // only-x86_64
7 // revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER
8 //
9 //[ASAN]         compile-flags: -Zsanitizer=address
10 //[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address
11 //[MSAN]         compile-flags: -Zsanitizer=memory
12 //[MSAN-RECOVER] compile-flags: -Zsanitizer=memory  -Zsanitizer-recover=memory
13
14 #![crate_type="lib"]
15
16 // ASAN-LABEL:         define i32 @penguin(
17 // ASAN-RECOVER-LABEL: define i32 @penguin(
18 // MSAN-LABEL:         define i32 @penguin(
19 // MSAN-RECOVER-LABEL: define i32 @penguin(
20 #[no_mangle]
21 pub fn penguin(p: &mut i32) -> i32 {
22     // ASAN:             call void @__asan_report_load4(i64 %0)
23     // ASAN:             unreachable
24     //
25     // ASAN-RECOVER:     call void @__asan_report_load4_noabort(
26     // ASAN-RECOVER-NOT: unreachable
27     //
28     // MSAN:             call void @__msan_warning_noreturn()
29     // MSAN:             unreachable
30     //
31     // MSAN-RECOVER:     call void @__msan_warning()
32     // MSAN-RECOVER-NOT: unreachable
33     *p
34 }