Skip to content

Commit

Permalink
asm: angrily drop clobbers of reserved registers
Browse files Browse the repository at this point in the history
  • Loading branch information
fw-immunant committed Apr 12, 2022
1 parent 5a121d8 commit 2c87960
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions c2rust-transpile/src/translator/assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,14 @@ impl<'c> Translation<'c> {
continue;
};

// We must drop clobbers of reserved registers, even though this
// really means we're not
let quoted = format!("\"{}\"", clobber);
if reg_is_reserved(&quoted).is_some() {
warn!("Attempting to clobber reserved register ({}), dropping clobber!", clobber);
continue;
}

tokens.push(TokenTree::Punct(Punct::new(',', Alone)));
let result = mk().call_expr(mk().ident_expr("out"), vec![mk().lit_expr(clobber)]);
push_expr(&mut tokens, result);
Expand Down

0 comments on commit 2c87960

Please sign in to comment.