Adds a stricter free spill slot check for GPR reservations in drreg. This is needed when there are multiple instrumentation passes that use drreg to spill GPR values to slots. In this case, we need to avoid slots that are in-use by prior instrumentation passes. The added logic looks at the remaining instrs in the given ilist after 'where'. Any spill slot usage after 'where' must have been added by a prior instrumentation pass and not the current one. To avoid spill slot conflicts, we should avoid using such spill slots with pending usage. This is not completely optimal as a spill slot may be available for use at some point in the ilist even if it is used later in the ilist. But we live with this sub-optimality.
Adds new drreg_bb_properties_t that enables the stricter free spill slot check (DRREG_HANDLE_MULTI_PHASE_SLOT_RESERVATIONS). This is currently set by drx_expand_scatter_gather.
Uses data area of label instrs marked with a special note to store information about spill slot usage, which is used in the new stricter free spill slot check.
Adds documentation about the new option, highlighting that it's necessary to enable this for multi-phase drreg reg reservations to work as intended, and that it is not enabled by default due to performance cost. Also documents that using this option may require adjustment to spill slot reservations made by the client.
Delays resetting bb_props to late in the instru2instru stage, in case stages besides insertion need to read it.
Extends drreg-test to verify that spill slots used in later phases do not conflict with those from earlier phases, with the new option enabled.
Adjust TLS slots reserved in drx_init. The existing logic of updating slots reserved
by drx if drx_expand_scatter_gather is invoked is racy. Instead, now we reserve
4 slots upfront in drx_init
. This strategy over-provisions drx if no scatter gather
instr is present, so we avoid it on Windows which is more sensitive to slot usage.
On Linux, slots are more plentiful so this is okay. drx will fall back to using DR slots
if it runs out of TLS slots, which may be slower. All these effects are limited to
scatter/gather instrs that are split into their own bbs.
Adding support for multi-phase reserve/restore for aflags is follow-up work.
Issue: #3823 (closed)