diff --git a/vyper/venom/basicblock.py b/vyper/venom/basicblock.py index 8d86da73e7..d5292da156 100644 --- a/vyper/venom/basicblock.py +++ b/vyper/venom/basicblock.py @@ -318,6 +318,12 @@ def get_outputs(self) -> list[IROperand]: """ return [self.output] if self.output else [] + def make_nop(self): + self.annotation = str(self) # Keep original instruction as annotation for debugging + self.opcode = "nop" + self.output = None + self.operands = [] + def flip(self): """ Flip operands for commutative or comparator opcodes @@ -601,9 +607,7 @@ def fix_phi_instructions(self): inst.opcode = "store" inst.operands = [inst.operands[1]] elif op_len == 0: - inst.opcode = "nop" - inst.output = None - inst.operands = [] + inst.make_nop() if needs_sort: self.instructions.sort(key=lambda inst: inst.opcode != "phi") diff --git a/vyper/venom/passes/sccp/sccp.py b/vyper/venom/passes/sccp/sccp.py index cee455e031..dbe5e607da 100644 --- a/vyper/venom/passes/sccp/sccp.py +++ b/vyper/venom/passes/sccp/sccp.py @@ -300,8 +300,7 @@ def _replace_constants(self, inst: IRInstruction): if isinstance(lat, IRLiteral): if lat.value > 0: - inst.opcode = "nop" - inst.operands = [] + inst.make_nop() else: raise StaticAssertionException( f"assertion found to fail at compile time ({inst.error_msg}).",