Auto merge of #50744 - nikic:mutable-noalias, r=alexcrichton

Emit noalias on &mut parameters by default

This used to be disabled due to LLVM bugs in the handling of
noalias information in conjunction with unwinding. However,
according to #31681 all known LLVM bugs have been fixed by
LLVM 6.0, so it's probably time to reenable this optimization.

-Z no-mutable-noalias is left as an escape-hatch to debug problems
suspected to stem from this change.
This commit is contained in:
bors 2018-05-19 07:42:03 +00:00
commit bdace29de0
3 changed files with 14 additions and 10 deletions

View file

@ -10,6 +10,7 @@
use abi::{FnType, FnTypeExt};
use common::*;
use llvm;
use rustc::hir;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout};
@ -428,8 +429,13 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
PointerKind::Shared
},
hir::MutMutable => {
if cx.tcx.sess.opts.debugging_opts.mutable_noalias ||
cx.tcx.sess.panic_strategy() == PanicStrategy::Abort {
// Only emit noalias annotations for LLVM >= 6 or in panic=abort
// mode, as prior versions had many bugs in conjunction with
// unwinding. See also issue #31681.
let mutable_noalias = cx.tcx.sess.opts.debugging_opts.mutable_noalias
.unwrap_or(unsafe { llvm::LLVMRustVersionMajor() >= 6 }
|| cx.tcx.sess.panic_strategy() == PanicStrategy::Abort);
if mutable_noalias {
PointerKind::UniqueBorrowed
} else {
PointerKind::Shared