diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-03-03 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2020-03-03 08:41:08 +0100 |
| commit | 52c5f2a577bdc5181af96eb6a2f82cd502f92f20 (patch) | |
| tree | af7c0ca82398da5312d8953752163611df69a01e | |
| parent | a61e13423e57380a08ea1475db57fc30cb7deb15 (diff) | |
| download | rust-52c5f2a577bdc5181af96eb6a2f82cd502f92f20.tar.gz rust-52c5f2a577bdc5181af96eb6a2f82cd502f92f20.zip | |
Add test for -Znew-llvm-pass-manager -Clto=thin -Zsanitizer=...
Additionally verify that the current implementation of LLVM version check (which uses lexicographic ordering) is good enough to exclude versions before LLVM 9, where the new LLVM pass manager is unsupported.
| -rw-r--r-- | src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs | 27 | ||||
| -rw-r--r-- | src/tools/compiletest/src/header/tests.rs | 18 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs b/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs new file mode 100644 index 00000000000..61d5d51cfd2 --- /dev/null +++ b/src/test/ui/sanitize/new-llvm-pass-manager-thin-lto.rs @@ -0,0 +1,27 @@ +// Regression test for sanitizer function instrumentation passes not +// being run when compiling with new LLVM pass manager and ThinLTO. +// Note: The issue occured only on non-zero opt-level. +// +// min-llvm-version 9.0 +// needs-sanitizer-support +// only-x86_64 +// +// no-prefer-dynamic +// revisions: opt0 opt1 +// compile-flags: -Znew-llvm-pass-manager=yes -Zsanitizer=address -Clto=thin +//[opt0]compile-flags: -Copt-level=0 +//[opt1]compile-flags: -Copt-level=1 +// run-fail +// 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); + } +} diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs index 38fa778219d..6c478f7e29d 100644 --- a/src/tools/compiletest/src/header/tests.rs +++ b/src/tools/compiletest/src/header/tests.rs @@ -110,6 +110,24 @@ fn no_system_llvm() { } #[test] +fn llvm_version() { + let mut config = config(); + + config.llvm_version = Some("8.1.2-rust".to_owned()); + assert!(parse_rs(&config, "// min-llvm-version 9.0").ignore); + + config.llvm_version = Some("9.0.1-rust-1.43.0-dev".to_owned()); + assert!(parse_rs(&config, "// min-llvm-version 9.2").ignore); + + config.llvm_version = Some("9.3.1-rust-1.43.0-dev".to_owned()); + assert!(!parse_rs(&config, "// min-llvm-version 9.2").ignore); + + // FIXME. + // config.llvm_version = Some("10.0.0-rust".to_owned()); + // assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore); +} + +#[test] fn ignore_target() { let mut config = config(); config.target = "x86_64-unknown-linux-gnu".to_owned(); |
