Skip to content

Commit 9fd3b18

Browse files
committed
Avoid depending on the unadjusted abi
It is ill defined and for this specific case it may become impossible to call using Cranelift in the future.
1 parent 0974099 commit 9fd3b18

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

src/abi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
156156
self.lib_call_unadjusted(name, params, returns, args)
157157
}
158158

159-
pub(crate) fn lib_call_unadjusted(
159+
fn lib_call_unadjusted(
160160
&mut self,
161161
name: &str,
162162
params: Vec<AbiParam>,

src/codegen_i128.rs

+6-21
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,6 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
8181
match bin_op {
8282
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => unreachable!(),
8383
BinOp::Add | BinOp::Sub => None,
84-
BinOp::Mul if is_signed => {
85-
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
86-
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
87-
let lhs = lhs.load_scalar(fx);
88-
let rhs = rhs.load_scalar(fx);
89-
let oflow_ptr = oflow.to_ptr().get_addr(fx);
90-
let res = fx.lib_call_unadjusted(
91-
"__muloti4",
92-
vec![
93-
AbiParam::new(types::I128),
94-
AbiParam::new(types::I128),
95-
AbiParam::new(fx.pointer_type),
96-
],
97-
vec![AbiParam::new(types::I128)],
98-
&[lhs, rhs, oflow_ptr],
99-
)[0];
100-
let oflow = oflow.to_cvalue(fx).load_scalar(fx);
101-
let oflow = fx.bcx.ins().ireduce(types::I8, oflow);
102-
Some(CValue::by_val_pair(res, oflow, fx.layout_of(out_ty)))
103-
}
10484
BinOp::Mul => {
10585
let out_ty = Ty::new_tup(fx.tcx, &[lhs.layout().ty, fx.tcx.types.bool]);
10686
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
@@ -110,7 +90,12 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
11090
AbiParam::new(types::I128),
11191
];
11292
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
113-
fx.lib_call("__rust_u128_mulo", param_types, vec![], &args);
93+
fx.lib_call(
94+
if is_signed { "__rust_i128_mulo" } else { "__rust_u128_mulo" },
95+
param_types,
96+
vec![],
97+
&args,
98+
);
11499
Some(out_place.to_cvalue(fx))
115100
}
116101
BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(),

0 commit comments

Comments
 (0)