Consistently use LLVM lifetime markers during codegen

Ensure that inliner inserts lifetime markers if they have been emitted during
codegen. Otherwise if allocas from inlined functions are merged together,
lifetime markers from one function might invalidate load & stores performed
by the other one.
This commit is contained in:
Tomasz Miąsko 2020-05-13 00:00:00 +00:00
parent 23ffeea307
commit bbb63d4554
7 changed files with 50 additions and 13 deletions

View file

@ -18,7 +18,6 @@ use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::config::{self, Sanitizer};
use rustc_target::abi::{self, Align, Size};
use rustc_target::spec::{HasTargetSpec, Target};
use std::borrow::Cow;
@ -1243,14 +1242,7 @@ impl Builder<'a, 'll, 'tcx> {
return;
}
let opts = &self.cx.sess().opts;
let emit = match opts.debugging_opts.sanitizer {
// Some sanitizer use lifetime intrinsics. When they are in use,
// emit lifetime intrinsics regardless of optimization level.
Some(Sanitizer::Address | Sanitizer::Memory) => true,
_ => opts.optimize != config::OptLevel::No,
};
if !emit {
if !self.cx().sess().emit_lifetime_markers() {
return;
}