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 xescapes if- 
ris used in any context besidesRef_assign (r, _)orRef_deref r - 
all uses
rreachable from a (direct or indirect) call toThread_copyCurrentare of the same flavor (eitherRef_assignorRef_deref); this also requires the Multi analysis. 
 - 
 - 
transformation
- 
rewrites
r = Ref_ref xtor = x - 
rewrites
_ = Ref_assign (r, y)tor = y - 
rewrites
z = Ref_deref rtoz = r 
Note that the resulting program violates the SSA condition.
 - 
 - 
Restore — restore the SSA condition.