Description
The side-effect condition pass (a codegen pass) can randomly fail with a "stage guard not found" type of error.
The problem seems to mostly occur because codegen performs dataflow simplification, which can replace or remove the relevant stage guard signal (e.g. stage_valid, pipeline_valid, etc.).
#1300 is one way to fix this- we could make replacing the stage guard be a supported operation that still allows the side-effect condition pass to get the needed signals.
Another way to fix this is to reorder the steps of codegen, e.g. delay delay dataflow simplification until after side-effects have been rewritten, or to have a placeholder for the stage guard during cloning so that we don't need a side-effect condition pass, we just replace the placeholder.