LocalRef is an optimization pass for the SSA IntermediateLanguage, invoked from SSASimplify.
Description
Implementation
Details and Notes
Moving a global ref requires the Multi analysis, because a global ref can only be moved into a function that is executed at most once.
Conversion of non-escaping ref`s is structured in three phases: * analysis -- a variable `r = Ref_ref x escapes if * r is used in any context besides Ref_assign (r, _) or Ref_deref r * all uses r reachable from a (direct or indirect) call to Thread_copyCurrent are of the same flavor (either Ref_assign or Ref_deref); this also requires the Multi analysis. * transformation * rewrites r = Ref_ref x to r = x * rewrites _ = Ref_assign (r, y) to r = y * rewrites z = Ref_deref r to z = r Note that the resulting program violates the SSA condition. * Restore — restore the SSA condition.