Skip to content

Commit

Permalink
Fix initial register value setting for I64 registers
Browse files Browse the repository at this point in the history
In particular, this affected registers with small range types.
  • Loading branch information
bacam committed Jul 19, 2024
1 parent 58bc827 commit be4327c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion isla-lib/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,18 @@ fn initialize_register<'ir, B: BV>(
letbindings: &Mutex<Bindings<'ir, B>>,
) {
if let Some(value) = initial_registers.get(id) {
// The value parser doesn't know what integer size to use, so correct it if necessary
let value = match (value, ty) {
(Val::I128(i), Ty::I64) => Val::I64(i64::try_from(*i).unwrap_or_else(|err| {
panic!("Bad initial value for {}: {}", shared_state.symtab.to_str(*id), err.to_string())
})),
(v, _) => v.clone(),
};
value
.plausible(ty, shared_state)
.unwrap_or_else(|err_msg| panic!("Bad initial value for {}: {}", shared_state.symtab.to_str(*id), err_msg));
let mut regs = registers.lock().unwrap();
regs.insert(*id, relaxed_registers.contains(id), UVal::Init(value.clone()));
regs.insert(*id, relaxed_registers.contains(id), UVal::Init(value));
} else {
{
let mut regs = registers.lock().unwrap();
Expand Down

0 comments on commit be4327c

Please sign in to comment.