about summary refs log tree commit diff
path: root/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs
blob: b66568474277e0bd7d7a4272d41df0e2d3650cd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Regression test for sanitizer function instrumentation passes not
// being run when compiling with new LLVM pass manager and ThinLTO.
// Note: The issue occurred only on non-zero opt-level.
//
//@ needs-sanitizer-support
//@ needs-sanitizer-address
//@ ignore-cross-compile
//
//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer
//
//@ no-prefer-dynamic
//@ revisions: opt0 opt1
//@ compile-flags: -Zsanitizer=address -Clto=thin
//@[opt0]compile-flags: -Copt-level=0
//@[opt1]compile-flags: -Copt-level=1
//@ run-fail-or-crash
//@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope

static mut P: *mut usize = std::ptr::null_mut();

fn main() {
    unsafe {
        {
            let mut x = 0;
            P = &mut x;
        }
        std::ptr::write_volatile(P, 123);
    }
}