- /* Make sure the recompiler isn't processing the block we'll
- * destroy */
- if (ENABLE_THREADED_COMPILER)
- lightrec_recompiler_remove(state->rec, block);
+ old_flags = block_set_flags(block, BLOCK_IS_DEAD);
+ if (!(old_flags & BLOCK_IS_DEAD)) {
+ /* Make sure the recompiler isn't processing the block
+ * we'll destroy */
+ if (ENABLE_THREADED_COMPILER)
+ lightrec_recompiler_remove(state->rec, block);
+
+ lightrec_unregister_block(state->block_cache, block);
+ remove_from_code_lut(state->block_cache, block);
+ lightrec_free_block(state, block);
+ }