Skip to content

Commit aacdce3

Browse files
committed
Remove check_overflow method from MiscMethods
It can be retrieved from the Session too.
1 parent 22b3243 commit aacdce3

File tree

4 files changed

+1
-18
lines changed

4 files changed

+1
-18
lines changed

compiler/rustc_codegen_gcc/src/context.rs

-8
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use crate::callee::get_fn;
2727
use crate::common::SignType;
2828

2929
pub struct CodegenCx<'gcc, 'tcx> {
30-
pub check_overflow: bool,
3130
pub codegen_unit: &'tcx CodegenUnit<'tcx>,
3231
pub context: &'gcc Context<'gcc>,
3332

@@ -134,8 +133,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
134133
tcx: TyCtxt<'tcx>,
135134
supports_128bit_integers: bool,
136135
) -> Self {
137-
let check_overflow = tcx.sess.overflow_checks();
138-
139136
let create_type = |ctype, rust_type| {
140137
let layout = tcx.layout_of(ParamEnv::reveal_all().and(rust_type)).unwrap();
141138
let align = layout.align.abi.bytes();
@@ -271,7 +268,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
271268
}
272269

273270
let mut cx = Self {
274-
check_overflow,
275271
codegen_unit,
276272
context,
277273
current_func: RefCell::new(None),
@@ -511,10 +507,6 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
511507
&self.tcx.sess
512508
}
513509

514-
fn check_overflow(&self) -> bool {
515-
self.check_overflow
516-
}
517-
518510
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
519511
self.codegen_unit
520512
}

compiler/rustc_codegen_llvm/src/context.rs

-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use std::str;
4444
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
4545
pub struct CodegenCx<'ll, 'tcx> {
4646
pub tcx: TyCtxt<'tcx>,
47-
pub check_overflow: bool,
4847
pub use_dll_storage_attrs: bool,
4948
pub tls_model: llvm::ThreadLocalMode,
5049

@@ -442,8 +441,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
442441
// start) and then strongly recommending static linkage on Windows!
443442
let use_dll_storage_attrs = tcx.sess.target.is_like_windows;
444443

445-
let check_overflow = tcx.sess.overflow_checks();
446-
447444
let tls_model = to_llvm_tls_model(tcx.sess.tls_model());
448445

449446
let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
@@ -467,7 +464,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
467464

468465
CodegenCx {
469466
tcx,
470-
check_overflow,
471467
use_dll_storage_attrs,
472468
tls_model,
473469
llmod,
@@ -606,10 +602,6 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
606602
self.tcx.sess
607603
}
608604

609-
fn check_overflow(&self) -> bool {
610-
self.check_overflow
611-
}
612-
613605
fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
614606
self.codegen_unit
615607
}

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
658658
// with #[rustc_inherit_overflow_checks] and inlined from
659659
// another crate (mostly core::num generic/#[inline] fns),
660660
// while the current crate doesn't use overflow checks.
661-
if !bx.cx().check_overflow() && msg.is_optional_overflow_check() {
661+
if !bx.sess().overflow_checks() && msg.is_optional_overflow_check() {
662662
const_cond = Some(expected);
663663
}
664664

compiler/rustc_codegen_ssa/src/traits/misc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1616
_vtable: Self::Value,
1717
) {
1818
}
19-
fn check_overflow(&self) -> bool;
2019
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
2120
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
2221
fn eh_personality(&self) -> Self::Value;

0 commit comments

Comments
 (0)