Emit noundef even for unoptimised code if msan is on
This commit is contained in:
parent
66dcf5dfee
commit
16525cc4c3
3 changed files with 16 additions and 2 deletions
|
@ -19,6 +19,7 @@ use rustc_target::abi::call::ArgAbi;
|
||||||
pub use rustc_target::abi::call::*;
|
pub use rustc_target::abi::call::*;
|
||||||
use rustc_target::abi::{self, HasDataLayout, Int};
|
use rustc_target::abi::{self, HasDataLayout, Int};
|
||||||
pub use rustc_target::spec::abi::Abi;
|
pub use rustc_target::spec::abi::Abi;
|
||||||
|
use rustc_target::spec::SanitizerSet;
|
||||||
|
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
|
@ -90,6 +91,13 @@ fn get_attrs<'ll>(this: &ArgAttributes, cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'
|
||||||
if regular.contains(ArgAttribute::NoAliasMutRef) && should_use_mutable_noalias(cx) {
|
if regular.contains(ArgAttribute::NoAliasMutRef) && should_use_mutable_noalias(cx) {
|
||||||
attrs.push(llvm::AttributeKind::NoAlias.create_attr(cx.llcx));
|
attrs.push(llvm::AttributeKind::NoAlias.create_attr(cx.llcx));
|
||||||
}
|
}
|
||||||
|
} else if cx.tcx.sess.opts.unstable_opts.sanitizer.contains(SanitizerSet::MEMORY) {
|
||||||
|
// If we're not optimising, *but* memory sanitizer is on, emit noundef, since it affects
|
||||||
|
// memory sanitizer's behavior.
|
||||||
|
|
||||||
|
if regular.contains(ArgAttribute::NoUndef) {
|
||||||
|
attrs.push(llvm::AttributeKind::NoUndef.create_attr(cx.llcx));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs
|
attrs
|
||||||
|
|
|
@ -2,7 +2,10 @@
|
||||||
// needs-sanitizer-memory
|
// needs-sanitizer-memory
|
||||||
// min-llvm-version: 14.0.0
|
// min-llvm-version: 14.0.0
|
||||||
//
|
//
|
||||||
// compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
|
// revisions: unoptimized optimized
|
||||||
|
//
|
||||||
|
// [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
|
||||||
|
// [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins
|
||||||
//
|
//
|
||||||
// run-fail
|
// run-fail
|
||||||
// error-pattern: MemorySanitizer: use-of-uninitialized-value
|
// error-pattern: MemorySanitizer: use-of-uninitialized-value
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
// needs-sanitizer-support
|
// needs-sanitizer-support
|
||||||
// needs-sanitizer-memory
|
// needs-sanitizer-memory
|
||||||
//
|
//
|
||||||
// compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
|
// revisions: unoptimized optimized
|
||||||
|
//
|
||||||
|
// [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O
|
||||||
|
// [unoptimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins
|
||||||
//
|
//
|
||||||
// run-fail
|
// run-fail
|
||||||
// error-pattern: MemorySanitizer: use-of-uninitialized-value
|
// error-pattern: MemorySanitizer: use-of-uninitialized-value
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue