Fixes 3 issues with IT state tracking for ad-hoc decoding/encoding uncovered by -stress_recreate_state:
-
Fixes a use-after-free by adding a hook in instr_destroy() to reset the IT state if the stored instruction is freed, along with a state reset in instrlist_clear().
-
On decode, limit advance-undo prior-instruction matching to the current instruction's Thumb size, to avoid incorrect advance-undo when switching between decoding sequences. Also, check for the current instruction being OP_it via raw byte checks to again avoid incorrect advance-undo.
-
On encode, walk backward to re-identify IT blocks after a state reset.
Tested on the forthcoming common.broadfun-stress test on ARM.
Issue: #4680 (closed)