Remove Session::no_landing_pads()
This commit is contained in:
parent
06e15a4ef9
commit
eb4725fc54
8 changed files with 14 additions and 15 deletions
|
@ -13,6 +13,7 @@ use rustc_middle::ty::query::Providers;
|
|||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_session::config::{OptLevel, Sanitizer};
|
||||
use rustc_session::Session;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
use crate::attributes;
|
||||
use crate::llvm::AttributePlace::Function;
|
||||
|
@ -270,7 +271,9 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
|
|||
//
|
||||
// You can also find more info on why Windows is whitelisted here in:
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
|
||||
if !cx.sess().no_landing_pads() || cx.sess().target.target.options.requires_uwtable {
|
||||
if cx.sess().panic_strategy() == PanicStrategy::Unwind
|
||||
|| cx.sess().target.target.options.requires_uwtable
|
||||
{
|
||||
attributes::emit_uwtable(llfn, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ use rustc_middle::ty::{self, Ty};
|
|||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::Span;
|
||||
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
use std::cmp::Ordering;
|
||||
use std::iter;
|
||||
|
@ -804,7 +805,7 @@ fn try_intrinsic(
|
|||
catch_func: &'ll Value,
|
||||
dest: &'ll Value,
|
||||
) {
|
||||
if bx.sess().no_landing_pads() {
|
||||
if bx.sess().panic_strategy() == PanicStrategy::Abort {
|
||||
bx.call(try_func, &[data], None);
|
||||
// Return 0 unconditionally from the intrinsic call;
|
||||
// we can never unwind.
|
||||
|
|
|
@ -36,7 +36,7 @@ use rustc_session::Session;
|
|||
use rustc_span::hygiene::ExpnId;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_target::spec::MergeFunctions;
|
||||
use rustc_target::spec::{MergeFunctions, PanicStrategy};
|
||||
|
||||
use std::any::Any;
|
||||
use std::fs;
|
||||
|
@ -1021,7 +1021,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
crate_types: sess.crate_types.borrow().clone(),
|
||||
each_linked_rlib_for_lto,
|
||||
lto: sess.lto(),
|
||||
no_landing_pads: sess.no_landing_pads(),
|
||||
no_landing_pads: sess.panic_strategy() == PanicStrategy::Abort,
|
||||
fewer_names: sess.fewer_names(),
|
||||
save_temps: sess.opts.cg.save_temps,
|
||||
opts: Arc::new(sess.opts.clone()),
|
||||
|
|
|
@ -68,6 +68,7 @@ use rustc_middle::ty::subst::SubstsRef;
|
|||
use rustc_middle::ty::GeneratorSubsts;
|
||||
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
|
||||
use rustc_target::abi::VariantIdx;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
use std::borrow::Cow;
|
||||
use std::iter;
|
||||
|
||||
|
@ -978,7 +979,7 @@ fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
|
|||
|
||||
fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
// Nothing can unwind when landing pads are off.
|
||||
if tcx.sess.no_landing_pads() {
|
||||
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::transform::{MirPass, MirSource};
|
|||
use rustc_middle::mir::visit::MutVisitor;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
pub struct NoLandingPads<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -23,7 +24,7 @@ impl<'tcx> MirPass<'tcx> for NoLandingPads<'tcx> {
|
|||
}
|
||||
|
||||
pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
if tcx.sess.no_landing_pads() {
|
||||
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
|
||||
NoLandingPads::new(tcx).visit_body(body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ use crate::util::patch::MirPatch;
|
|||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_target::spec::PanicStrategy;
|
||||
|
||||
/// A pass that removes noop landing pads and replaces jumps to them with
|
||||
/// `None`. This is important because otherwise LLVM generates terrible
|
||||
|
@ -10,7 +11,7 @@ use rustc_middle::ty::TyCtxt;
|
|||
pub struct RemoveNoopLandingPads;
|
||||
|
||||
pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
if tcx.sess.no_landing_pads() {
|
||||
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
|
||||
return;
|
||||
}
|
||||
debug!("remove_noop_landing_pads({:?})", body);
|
||||
|
|
|
@ -533,11 +533,6 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, _abi: Abi) -> b
|
|||
return false;
|
||||
}
|
||||
|
||||
// We cannot add landing pads, so don't add one.
|
||||
if tcx.sess.no_landing_pads() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is a special case: some functions have a C abi but are meant to
|
||||
// unwind anyway. Don't stop them.
|
||||
match unwind_attr {
|
||||
|
|
|
@ -540,9 +540,6 @@ impl Session {
|
|||
self.opts.debugging_opts.fewer_names || !more_names
|
||||
}
|
||||
|
||||
pub fn no_landing_pads(&self) -> bool {
|
||||
self.panic_strategy() == PanicStrategy::Abort
|
||||
}
|
||||
pub fn unstable_options(&self) -> bool {
|
||||
self.opts.debugging_opts.unstable_options
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue