Interprocedual analysis for the creation of transactional clones.
The aim of this pass is to find which functions are referenced in
a non-irrevocable transaction context, and for those over which
we have control (or user directive), create a version of the
function which uses only the transactional interface to reference
protected memories. This analysis proceeds in several steps:
(1) Collect the set of all possible transactional clones:
(a) For all local public functions marked tm_callable, push
it onto the tm_callee queue.
(b) For all local functions, scan for calls in transaction blocks.
Push the caller and callee onto the tm_caller and tm_callee
queues. Count the number of callers for each callee.
(c) For each local function on the callee list, assume we will
create a transactional clone. Push *all* calls onto the
callee queues; count the number of clone callers separately
to the number of original callers.
(2) Propagate irrevocable status up the dominator tree:
(a) Any external function on the callee list that is not marked
tm_callable is irrevocable. Push all callers of such onto
a worklist.
(b) For each function on the worklist, mark each block that
contains an irrevocable call. Use the AND operator to
propagate that mark up the dominator tree.
(c) If we reach the entry block for a possible transactional
clone, then the transactional clone is irrevocable, and
we should not create the clone after all. Push all
callers onto the worklist.
(d) Place tm_irrevocable calls at the beginning of the relevant
blocks. Special case here is the entry block for the entire
transaction region; there we mark it GTMA_DOES_GO_IRREVOCABLE for
the library to begin the region in serial mode. Decrement
the call count for all callees in the irrevocable region.
(3) Create the transactional clones:
Any tm_callee that still has a non-zero call count is cloned.
This structure is stored in the AUX field of each cgraph_node.