]> git.lizzy.rs Git - rust.git/blob - tests/codegen/sanitizer-no-sanitize-inlining.rs
Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitor
[rust.git] / tests / codegen / sanitizer-no-sanitize-inlining.rs
1 // Verifies that no_sanitize attribute prevents inlining when
2 // given sanitizer is enabled, but has no effect on inlining otherwise.
3 //
4 // needs-sanitizer-address
5 // needs-sanitizer-leak
6 // revisions: ASAN LSAN
7 //[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=4
8 //[LSAN] compile-flags: -Zsanitizer=leak    -C opt-level=3 -Z mir-opt-level=4
9
10 #![crate_type="lib"]
11 #![feature(no_sanitize)]
12
13 // ASAN-LABEL: define void @test
14 // ASAN:         call {{.*}} @random_inline
15 // ASAN:       }
16 //
17 // LSAN-LABEL: define void @test
18 // LSAN-NO:      call
19 // LSAN:       }
20 #[no_mangle]
21 pub fn test(n: &mut u32) {
22     random_inline(n);
23 }
24
25 #[no_sanitize(address)]
26 #[inline]
27 #[no_mangle]
28 pub fn random_inline(n: &mut u32) {
29     *n = 42;
30 }