Skip to content

Commit

Permalink
Fix regression on gen_import_call_trampoline_arm64()
Browse files Browse the repository at this point in the history
`Fix clippy lints #2942` changed the
`gen_import_call_trampoline_arm64()` code because clippy emitted a lint
about the loop logic. However, the fix was wrong and was causing
incorrect binary generation on arm64.

More precisely, this was caught by test
serialize::test_deserialize::singlepass::* on macos M1 (arm64)
  • Loading branch information
epilys committed Jun 13, 2022
1 parent c9f406c commit 15ff6b9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/compiler-singlepass/src/emitter_arm64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2739,14 +2739,20 @@ pub fn gen_import_call_trampoline_arm64(
GPR::X6,
GPR::X7,
];
let gpr_iter = PARAM_REGS.iter().map(|r| Location::GPR(*r));
let memory_iter =
(0i32..).map(|i| Location::Memory(GPR::XzrSp, stack_offset + i * 8));

let param_locations: Vec<Location> = gpr_iter
.chain(memory_iter)
.take(sig.params().len())
.collect();
let mut param_locations = vec![];
/* Clippy is wrong about using `i` to index `PARAM_REGS` here. */
#[allow(clippy::needless_range_loop)]
for i in 0..sig.params().len() {
let loc = match i {
0..=6 => {
let loc = Location::Memory(GPR::XzrSp, (i * 8) as i32);
a.emit_str(Size::S64, Location::GPR(PARAM_REGS[i]), loc);
loc
}
_ => Location::Memory(GPR::XzrSp, stack_offset + ((i - 7) * 8) as i32),
};
param_locations.push(loc);
}

// Copy arguments.
let mut caller_stack_offset: i32 = 0;
Expand Down

0 comments on commit 15ff6b9

Please sign in to comment.