Skip to content

Commit dd2bd5b

Browse files
committed
evaluate arguments first, not inside the logic
1 parent ed83f1a commit dd2bd5b

File tree

1 file changed

+7
-2
lines changed
  • src/tools/miri/src/shims/x86

1 file changed

+7
-2
lines changed

src/tools/miri/src/shims/x86/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,20 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6464
"addcarryx.u32" | "addcarryx.u64" => {
6565
this.expect_target_feature_for_intrinsic(link_name, "adx")?;
6666

67-
if unprefixed_name.ends_with("64") && this.tcx.sess.target.arch != "x86_64" {
67+
let is_u64 = unprefixed_name.ends_with("64");
68+
if is_u64 && this.tcx.sess.target.arch != "x86_64" {
6869
return Ok(EmulateItemResult::NotSupported);
6970
}
7071

7172
let [c_in, a, b, out] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
73+
let out = this.deref_pointer_as(
74+
out,
75+
if is_u64 { this.machine.layouts.u64 } else { this.machine.layouts.u32 },
76+
)?;
7277

7378
let (sum, c_out) = carrying_add(this, c_in, a, b, mir::BinOp::AddWithOverflow)?;
7479
this.write_scalar(c_out, dest)?;
75-
this.write_immediate(*sum, &this.deref_pointer_as(out, sum.layout)?)?;
80+
this.write_immediate(*sum, &out)?;
7681
}
7782

7883
// Used to implement the `_mm_pause` function.

0 commit comments

Comments
 (0)