Skip to content

Commit eb4725f

Browse files
committed
Remove Session::no_landing_pads()
1 parent 06e15a4 commit eb4725f

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

src/librustc_codegen_llvm/attributes.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_middle::ty::query::Providers;
1313
use rustc_middle::ty::{self, TyCtxt};
1414
use rustc_session::config::{OptLevel, Sanitizer};
1515
use rustc_session::Session;
16+
use rustc_target::spec::PanicStrategy;
1617

1718
use crate::attributes;
1819
use crate::llvm::AttributePlace::Function;
@@ -270,7 +271,9 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
270271
//
271272
// You can also find more info on why Windows is whitelisted here in:
272273
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
273-
if !cx.sess().no_landing_pads() || cx.sess().target.target.options.requires_uwtable {
274+
if cx.sess().panic_strategy() == PanicStrategy::Unwind
275+
|| cx.sess().target.target.options.requires_uwtable
276+
{
274277
attributes::emit_uwtable(llfn, true);
275278
}
276279

src/librustc_codegen_llvm/intrinsic.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_middle::ty::{self, Ty};
2222
use rustc_middle::{bug, span_bug};
2323
use rustc_span::Span;
2424
use rustc_target::abi::{self, HasDataLayout, LayoutOf, Primitive};
25+
use rustc_target::spec::PanicStrategy;
2526

2627
use std::cmp::Ordering;
2728
use std::iter;
@@ -804,7 +805,7 @@ fn try_intrinsic(
804805
catch_func: &'ll Value,
805806
dest: &'ll Value,
806807
) {
807-
if bx.sess().no_landing_pads() {
808+
if bx.sess().panic_strategy() == PanicStrategy::Abort {
808809
bx.call(try_func, &[data], None);
809810
// Return 0 unconditionally from the intrinsic call;
810811
// we can never unwind.

src/librustc_codegen_ssa/back/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_session::Session;
3636
use rustc_span::hygiene::ExpnId;
3737
use rustc_span::source_map::SourceMap;
3838
use rustc_span::symbol::{sym, Symbol};
39-
use rustc_target::spec::MergeFunctions;
39+
use rustc_target::spec::{MergeFunctions, PanicStrategy};
4040

4141
use std::any::Any;
4242
use std::fs;
@@ -1021,7 +1021,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
10211021
crate_types: sess.crate_types.borrow().clone(),
10221022
each_linked_rlib_for_lto,
10231023
lto: sess.lto(),
1024-
no_landing_pads: sess.no_landing_pads(),
1024+
no_landing_pads: sess.panic_strategy() == PanicStrategy::Abort,
10251025
fewer_names: sess.fewer_names(),
10261026
save_temps: sess.opts.cg.save_temps,
10271027
opts: Arc::new(sess.opts.clone()),

src/librustc_mir/transform/generator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use rustc_middle::ty::subst::SubstsRef;
6868
use rustc_middle::ty::GeneratorSubsts;
6969
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt};
7070
use rustc_target::abi::VariantIdx;
71+
use rustc_target::spec::PanicStrategy;
7172
use std::borrow::Cow;
7273
use std::iter;
7374

@@ -978,7 +979,7 @@ fn can_return<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
978979

979980
fn can_unwind<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) -> bool {
980981
// Nothing can unwind when landing pads are off.
981-
if tcx.sess.no_landing_pads() {
982+
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
982983
return false;
983984
}
984985

src/librustc_mir/transform/no_landing_pads.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::transform::{MirPass, MirSource};
55
use rustc_middle::mir::visit::MutVisitor;
66
use rustc_middle::mir::*;
77
use rustc_middle::ty::TyCtxt;
8+
use rustc_target::spec::PanicStrategy;
89

910
pub struct NoLandingPads<'tcx> {
1011
tcx: TyCtxt<'tcx>,
@@ -23,7 +24,7 @@ impl<'tcx> MirPass<'tcx> for NoLandingPads<'tcx> {
2324
}
2425

2526
pub fn no_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
26-
if tcx.sess.no_landing_pads() {
27+
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
2728
NoLandingPads::new(tcx).visit_body(body);
2829
}
2930
}

src/librustc_mir/transform/remove_noop_landing_pads.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ use crate::util::patch::MirPatch;
33
use rustc_index::bit_set::BitSet;
44
use rustc_middle::mir::*;
55
use rustc_middle::ty::TyCtxt;
6+
use rustc_target::spec::PanicStrategy;
67

78
/// A pass that removes noop landing pads and replaces jumps to them with
89
/// `None`. This is important because otherwise LLVM generates terrible
910
/// code for these.
1011
pub struct RemoveNoopLandingPads;
1112

1213
pub fn remove_noop_landing_pads<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
13-
if tcx.sess.no_landing_pads() {
14+
if tcx.sess.panic_strategy() == PanicStrategy::Abort {
1415
return;
1516
}
1617
debug!("remove_noop_landing_pads({:?})", body);

src/librustc_mir_build/build/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,6 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: LocalDefId, _abi: Abi) -> b
533533
return false;
534534
}
535535

536-
// We cannot add landing pads, so don't add one.
537-
if tcx.sess.no_landing_pads() {
538-
return false;
539-
}
540-
541536
// This is a special case: some functions have a C abi but are meant to
542537
// unwind anyway. Don't stop them.
543538
match unwind_attr {

src/librustc_session/session.rs

-3
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,6 @@ impl Session {
540540
self.opts.debugging_opts.fewer_names || !more_names
541541
}
542542

543-
pub fn no_landing_pads(&self) -> bool {
544-
self.panic_strategy() == PanicStrategy::Abort
545-
}
546543
pub fn unstable_options(&self) -> bool {
547544
self.opts.debugging_opts.unstable_options
548545
}

0 commit comments

Comments
 (0)