Revamps the drreg state restoration logic in drreg_event_restore_state to correctly handle various corner cases like multiple restores (i#4939), aflags in reg (i#4933) and multi-phase use (i#3823).
Makes the reconstructed ilist available to drreg_event_restore_state. This is needed for determining whether some instr is app or tool.
The new logic looks at the complete ilist to track the movement of the app value of gpr/aflags across spills and restores. The native value can be in the gpr/aflags itself or one or more spill slots. We do not forget a spill slot on seeing one restore (which caused i#4939), but remember that the app value can still be found in the spill slot, in addition to the gpr itself. Instead, a spill slot is forgotten when it is used to spill some other reg. We also track whether gprs/aflags contain their native app value or not. This helps in handling cases of overlapping or nested spill regions arising out of multi-phase use of drreg. Tool writes (except restores) to gprs/aflags clobber the native value. App writes to gprs/aflags install a native value and invalidate the value in the reg's spill slot. Restores from spill slots also install a native value. We also track movement of aflags to registers more robustly (to fix i#4933).
Adds tests for the i#4939, i#4933, i#3823 (gpr case, not aflags). Test for i#3823 aflags case will be added in PR #4917.
Issue: #4933 (closed), #4939 (closed), #3823 (closed), #3801 Fixes: #4933 (closed) Fixes: #4939 (closed)