Skip to content

Commit 52c5f2a

Browse files
committed
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.
1 parent a61e134 commit 52c5f2a

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Regression test for sanitizer function instrumentation passes not
2+
// being run when compiling with new LLVM pass manager and ThinLTO.
3+
// Note: The issue occured only on non-zero opt-level.
4+
//
5+
// min-llvm-version 9.0
6+
// needs-sanitizer-support
7+
// only-x86_64
8+
//
9+
// no-prefer-dynamic
10+
// revisions: opt0 opt1
11+
// compile-flags: -Znew-llvm-pass-manager=yes -Zsanitizer=address -Clto=thin
12+
//[opt0]compile-flags: -Copt-level=0
13+
//[opt1]compile-flags: -Copt-level=1
14+
// run-fail
15+
// error-pattern: ERROR: AddressSanitizer: stack-use-after-scope
16+
17+
static mut P: *mut usize = std::ptr::null_mut();
18+
19+
fn main() {
20+
unsafe {
21+
{
22+
let mut x = 0;
23+
P = &mut x;
24+
}
25+
std::ptr::write_volatile(P, 123);
26+
}
27+
}

src/tools/compiletest/src/header/tests.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,24 @@ fn no_system_llvm() {
109109
assert!(parse_rs(&config, "// no-system-llvm").ignore);
110110
}
111111

112+
#[test]
113+
fn llvm_version() {
114+
let mut config = config();
115+
116+
config.llvm_version = Some("8.1.2-rust".to_owned());
117+
assert!(parse_rs(&config, "// min-llvm-version 9.0").ignore);
118+
119+
config.llvm_version = Some("9.0.1-rust-1.43.0-dev".to_owned());
120+
assert!(parse_rs(&config, "// min-llvm-version 9.2").ignore);
121+
122+
config.llvm_version = Some("9.3.1-rust-1.43.0-dev".to_owned());
123+
assert!(!parse_rs(&config, "// min-llvm-version 9.2").ignore);
124+
125+
// FIXME.
126+
// config.llvm_version = Some("10.0.0-rust".to_owned());
127+
// assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore);
128+
}
129+
112130
#[test]
113131
fn ignore_target() {
114132
let mut config = config();

0 commit comments

Comments
 (0)