diff options
| author | 5225225 <5225225@mailbox.org> | 2022-07-16 12:08:48 +0100 |
|---|---|---|
| committer | 5225225 <5225225@mailbox.org> | 2022-08-14 10:37:13 +0100 |
| commit | 16525cc4c34649c564e9544ec1d9c45c4c4f4e52 (patch) | |
| tree | c648cac74596f9bc0e3348c9b31ea36375a78380 /compiler/rustc_codegen_llvm | |
| parent | 66dcf5dfee0942d09d7a030a5c891d0a79cd8426 (diff) | |
| download | rust-16525cc4c34649c564e9544ec1d9c45c4c4f4e52.tar.gz rust-16525cc4c34649c564e9544ec1d9c45c4c4f4e52.zip | |
Emit noundef even for unoptimised code if msan is on
Diffstat (limited to 'compiler/rustc_codegen_llvm')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/abi.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 9eb3574e77b..461be98f210 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -19,6 +19,7 @@ use rustc_target::abi::call::ArgAbi; pub use rustc_target::abi::call::*; use rustc_target::abi::{self, HasDataLayout, Int}; pub use rustc_target::spec::abi::Abi; +use rustc_target::spec::SanitizerSet; use libc::c_uint; 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) { 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 |
