basicblock: use state monad to save all targets from previous pass