Skip to main content

luaur_code_gen/functions/
has_side_effects.rs

1use crate::enums::ir_cmd::IrCmd;
2use crate::functions::has_result::has_result;
3use crate::functions::is_pseudo::is_pseudo;
4
5pub fn has_side_effects(cmd: IrCmd) -> bool {
6    if cmd == IrCmd::INVOKE_FASTCALL {
7        return true;
8    }
9
10    if is_pseudo(cmd) {
11        return false;
12    }
13
14    // Instructions that don't produce a result most likely have other side-effects to make them useful
15    // Right now, a full switch would mirror the 'hasResult' function, so we use this simple condition
16    !has_result(cmd)
17}