Skip to content

Commit 3427a14

Browse files
committed
Remove support for -Zlower-128bit-ops
It is broken and unused
1 parent f9477a7 commit 3427a14

File tree

8 files changed

+3
-325
lines changed

8 files changed

+3
-325
lines changed

src/librustc/middle/lang_items.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -367,34 +367,6 @@ language_item_table! {
367367

368368
DebugTraitLangItem, "debug_trait", debug_trait, Target::Trait;
369369

370-
// A lang item for each of the 128-bit operators we can optionally lower.
371-
I128AddFnLangItem, "i128_add", i128_add_fn, Target::Fn;
372-
U128AddFnLangItem, "u128_add", u128_add_fn, Target::Fn;
373-
I128SubFnLangItem, "i128_sub", i128_sub_fn, Target::Fn;
374-
U128SubFnLangItem, "u128_sub", u128_sub_fn, Target::Fn;
375-
I128MulFnLangItem, "i128_mul", i128_mul_fn, Target::Fn;
376-
U128MulFnLangItem, "u128_mul", u128_mul_fn, Target::Fn;
377-
I128DivFnLangItem, "i128_div", i128_div_fn, Target::Fn;
378-
U128DivFnLangItem, "u128_div", u128_div_fn, Target::Fn;
379-
I128RemFnLangItem, "i128_rem", i128_rem_fn, Target::Fn;
380-
U128RemFnLangItem, "u128_rem", u128_rem_fn, Target::Fn;
381-
I128ShlFnLangItem, "i128_shl", i128_shl_fn, Target::Fn;
382-
U128ShlFnLangItem, "u128_shl", u128_shl_fn, Target::Fn;
383-
I128ShrFnLangItem, "i128_shr", i128_shr_fn, Target::Fn;
384-
U128ShrFnLangItem, "u128_shr", u128_shr_fn, Target::Fn;
385-
// And overflow versions for the operators that are checkable.
386-
// While MIR calls these Checked*, they return (T,bool), not Option<T>.
387-
I128AddoFnLangItem, "i128_addo", i128_addo_fn, Target::Fn;
388-
U128AddoFnLangItem, "u128_addo", u128_addo_fn, Target::Fn;
389-
I128SuboFnLangItem, "i128_subo", i128_subo_fn, Target::Fn;
390-
U128SuboFnLangItem, "u128_subo", u128_subo_fn, Target::Fn;
391-
I128MuloFnLangItem, "i128_mulo", i128_mulo_fn, Target::Fn;
392-
U128MuloFnLangItem, "u128_mulo", u128_mulo_fn, Target::Fn;
393-
I128ShloFnLangItem, "i128_shlo", i128_shlo_fn, Target::Fn;
394-
U128ShloFnLangItem, "u128_shlo", u128_shlo_fn, Target::Fn;
395-
I128ShroFnLangItem, "i128_shro", i128_shro_fn, Target::Fn;
396-
U128ShroFnLangItem, "u128_shro", u128_shro_fn, Target::Fn;
397-
398370
// Align offset for stride != 1, must not panic.
399371
AlignOffsetLangItem, "align_offset", align_offset_fn, Target::Fn;
400372

src/librustc/session/config.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,10 +1406,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
14061406
saturating_float_casts: bool = (false, parse_bool, [TRACKED],
14071407
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
14081408
the max/min integer respectively, and NaN is mapped to 0"),
1409-
lower_128bit_ops: Option<bool> = (None, parse_opt_bool, [TRACKED],
1410-
"rewrite operators on i128 and u128 into lang item calls (typically provided \
1411-
by compiler-builtins) so codegen doesn't need to support them,
1412-
overriding the default for the current target"),
14131409
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
14141410
"generate human-readable, predictable names for codegen units"),
14151411
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],

src/librustc/ty/context.rs

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::middle::cstore::EncodedMetadata;
2121
use crate::middle::lang_items;
2222
use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
2323
use crate::middle::stability;
24-
use crate::mir::{self, Body, interpret, ProjectionKind};
24+
use crate::mir::{Body, interpret, ProjectionKind};
2525
use crate::mir::interpret::{ConstValue, Allocation, Scalar};
2626
use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, Subst};
2727
use crate::ty::ReprOptions;
@@ -1297,40 +1297,6 @@ impl<'tcx> TyCtxt<'tcx> {
12971297
self.get_lang_items(LOCAL_CRATE)
12981298
}
12991299

1300-
/// Due to missing llvm support for lowering 128 bit math to software emulation
1301-
/// (on some targets), the lowering can be done in MIR.
1302-
///
1303-
/// This function only exists until said support is implemented.
1304-
pub fn is_binop_lang_item(&self, def_id: DefId) -> Option<(mir::BinOp, bool)> {
1305-
let items = self.lang_items();
1306-
let def_id = Some(def_id);
1307-
if items.i128_add_fn() == def_id { Some((mir::BinOp::Add, false)) }
1308-
else if items.u128_add_fn() == def_id { Some((mir::BinOp::Add, false)) }
1309-
else if items.i128_sub_fn() == def_id { Some((mir::BinOp::Sub, false)) }
1310-
else if items.u128_sub_fn() == def_id { Some((mir::BinOp::Sub, false)) }
1311-
else if items.i128_mul_fn() == def_id { Some((mir::BinOp::Mul, false)) }
1312-
else if items.u128_mul_fn() == def_id { Some((mir::BinOp::Mul, false)) }
1313-
else if items.i128_div_fn() == def_id { Some((mir::BinOp::Div, false)) }
1314-
else if items.u128_div_fn() == def_id { Some((mir::BinOp::Div, false)) }
1315-
else if items.i128_rem_fn() == def_id { Some((mir::BinOp::Rem, false)) }
1316-
else if items.u128_rem_fn() == def_id { Some((mir::BinOp::Rem, false)) }
1317-
else if items.i128_shl_fn() == def_id { Some((mir::BinOp::Shl, false)) }
1318-
else if items.u128_shl_fn() == def_id { Some((mir::BinOp::Shl, false)) }
1319-
else if items.i128_shr_fn() == def_id { Some((mir::BinOp::Shr, false)) }
1320-
else if items.u128_shr_fn() == def_id { Some((mir::BinOp::Shr, false)) }
1321-
else if items.i128_addo_fn() == def_id { Some((mir::BinOp::Add, true)) }
1322-
else if items.u128_addo_fn() == def_id { Some((mir::BinOp::Add, true)) }
1323-
else if items.i128_subo_fn() == def_id { Some((mir::BinOp::Sub, true)) }
1324-
else if items.u128_subo_fn() == def_id { Some((mir::BinOp::Sub, true)) }
1325-
else if items.i128_mulo_fn() == def_id { Some((mir::BinOp::Mul, true)) }
1326-
else if items.u128_mulo_fn() == def_id { Some((mir::BinOp::Mul, true)) }
1327-
else if items.i128_shlo_fn() == def_id { Some((mir::BinOp::Shl, true)) }
1328-
else if items.u128_shlo_fn() == def_id { Some((mir::BinOp::Shl, true)) }
1329-
else if items.i128_shro_fn() == def_id { Some((mir::BinOp::Shr, true)) }
1330-
else if items.u128_shro_fn() == def_id { Some((mir::BinOp::Shr, true)) }
1331-
else { None }
1332-
}
1333-
13341300
pub fn stability(self) -> &'tcx stability::Index<'tcx> {
13351301
self.stability_index(LOCAL_CRATE)
13361302
}

src/librustc_mir/interpret/intrinsics.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,21 +230,10 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
230230
&mut self,
231231
instance: ty::Instance<'tcx>,
232232
args: &[OpTy<'tcx, M::PointerTag>],
233-
dest: Option<PlaceTy<'tcx, M::PointerTag>>,
233+
_dest: Option<PlaceTy<'tcx, M::PointerTag>>,
234234
) -> InterpResult<'tcx, bool> {
235235
let def_id = instance.def_id();
236-
// Some fn calls are actually BinOp intrinsics
237-
if let Some((op, oflo)) = self.tcx.is_binop_lang_item(def_id) {
238-
let dest = dest.expect("128 lowerings can't diverge");
239-
let l = self.read_immediate(args[0])?;
240-
let r = self.read_immediate(args[1])?;
241-
if oflo {
242-
self.binop_with_overflow(op, l, r, dest)?;
243-
} else {
244-
self.binop_ignore_overflow(op, l, r, dest)?;
245-
}
246-
return Ok(true);
247-
} else if Some(def_id) == self.tcx.lang_items().panic_fn() {
236+
if Some(def_id) == self.tcx.lang_items().panic_fn() {
248237
assert!(args.len() == 1);
249238
// &(&'static str, &'static str, u32, u32)
250239
let place = self.deref_operand(args[0])?;

src/librustc_mir/transform/inline.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,6 @@ impl Inliner<'tcx> {
232232
return false;
233233
}
234234

235-
// Do not inline {u,i}128 lang items, codegen const eval depends
236-
// on detecting calls to these lang items and intercepting them
237-
if tcx.is_binop_lang_item(callsite.callee).is_some() {
238-
debug!(" not inlining 128bit integer lang item");
239-
return false;
240-
}
241-
242235
let codegen_fn_attrs = tcx.codegen_fn_attrs(callsite.callee);
243236

244237
let hinted = match codegen_fn_attrs.inline {

src/librustc_mir/transform/lower_128bit.rs

Lines changed: 0 additions & 230 deletions
This file was deleted.

src/librustc_mir/transform/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub mod copy_prop;
3434
pub mod const_prop;
3535
pub mod generator;
3636
pub mod inline;
37-
pub mod lower_128bit;
3837
pub mod uniform_array_move_out;
3938

4039
pub(crate) fn provide(providers: &mut Providers<'_>) {
@@ -272,8 +271,6 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
272271
// From here on out, regions are gone.
273272
&erase_regions::EraseRegions,
274273

275-
&lower_128bit::Lower128Bit,
276-
277274

278275
// Optimizations begin.
279276
&uniform_array_move_out::RestoreSubsliceArrayMoveOut,

0 commit comments

Comments
 (0)