]> git.lizzy.rs Git - rust.git/blob - tests/codegen/sanitizer-memory-track-orgins.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / codegen / sanitizer-memory-track-orgins.rs
1 // Verifies that MemorySanitizer track-origins level can be controlled
2 // with -Zsanitizer-memory-track-origins option.
3 //
4 // needs-sanitizer-memory
5 // revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO
6 //
7 //[MSAN-0] compile-flags: -Zsanitizer=memory
8 //[MSAN-1] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1
9 //[MSAN-2] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins
10 //[MSAN-1-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins=1 -C lto=fat
11 //[MSAN-2-LTO] compile-flags: -Zsanitizer=memory -Zsanitizer-memory-track-origins -C lto=fat
12
13 #![crate_type="lib"]
14
15 // MSAN-0-NOT: @__msan_track_origins
16 // MSAN-1:     @__msan_track_origins = weak_odr {{.*}}constant i32 1
17 // MSAN-2:     @__msan_track_origins = weak_odr {{.*}}constant i32 2
18 // MSAN-1-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 1
19 // MSAN-2-LTO: @__msan_track_origins = weak_odr {{.*}}constant i32 2
20 //
21 // MSAN-0-LABEL: define void @copy(
22 // MSAN-1-LABEL: define void @copy(
23 // MSAN-2-LABEL: define void @copy(
24 #[no_mangle]
25 pub fn copy(dst: &mut i32, src: &i32) {
26     // MSAN-0-NOT: call i32 @__msan_chain_origin(
27     // MSAN-1-NOT: call i32 @__msan_chain_origin(
28     // MSAN-2:     call i32 @__msan_chain_origin(
29     *dst = *src;
30 }