]> git.lizzy.rs Git - rust.git/blob - tests/codegen/sanitizer-recover.rs
Auto merge of #107778 - weihanglo:update-cargo, r=weihanglo
[rust.git] / tests / codegen / sanitizer-recover.rs
1 // Verifies that AddressSanitizer and MemorySanitizer
2 // recovery mode can be enabled with -Zsanitizer-recover.
3 //
4 // needs-sanitizer-address
5 // needs-sanitizer-memory
6 // revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO
7 // no-prefer-dynamic
8 //
9 //[ASAN]             compile-flags: -Zsanitizer=address -Copt-level=0
10 //[ASAN-RECOVER]     compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0
11 //[MSAN]             compile-flags: -Zsanitizer=memory
12 //[MSAN-RECOVER]     compile-flags: -Zsanitizer=memory  -Zsanitizer-recover=memory
13 //[MSAN-RECOVER-LTO] compile-flags: -Zsanitizer=memory  -Zsanitizer-recover=memory -C lto=fat
14 //
15 // MSAN-NOT:         @__msan_keep_going
16 // MSAN-RECOVER:     @__msan_keep_going = weak_odr {{.*}}constant i32 1
17 // MSAN-RECOVER-LTO: @__msan_keep_going = weak_odr {{.*}}constant i32 1
18
19 // ASAN-LABEL: define dso_local i32 @penguin(
20 // ASAN:         call void @__asan_report_load4(i64 %0)
21 // ASAN:         unreachable
22 // ASAN:       }
23 //
24 // ASAN-RECOVER-LABEL: define dso_local i32 @penguin(
25 // ASAN-RECOVER:         call void @__asan_report_load4_noabort(
26 // ASAN-RECOVER-NOT:     unreachable
27 // ASAN:               }
28 //
29 // MSAN-LABEL: define dso_local noundef i32 @penguin(
30 // MSAN:         call void @__msan_warning{{(_with_origin_noreturn\(i32 0\)|_noreturn\(\))}}
31 // MSAN:         unreachable
32 // MSAN:       }
33 //
34 // MSAN-RECOVER-LABEL: define dso_local noundef i32 @penguin(
35 // MSAN-RECOVER:         call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}}
36 // MSAN-RECOVER-NOT:     unreachable
37 // MSAN-RECOVER:       }
38 //
39 // MSAN-RECOVER-LTO-LABEL: define dso_local noundef i32 @penguin(
40 // MSAN-RECOVER-LTO:          call void @__msan_warning{{(_with_origin\(i32 0\)|\(\))}}
41 // MSAN-RECOVER-LTO-NOT:      unreachable
42 // MSAN-RECOVER-LTO:       }
43 //
44 #[no_mangle]
45 pub fn penguin(p: &mut i32) -> i32 {
46     *p
47 }
48
49 fn main() {}