checkpointing codegen