Through LivermoreLoop issue https://github.com/SacBase/LivermoreLoops/issues/5, it was discovered that EMRL can cause a race condition. Specifically, by design EMRL must find a suitable matching avis to use as part of a buffer-swap otherwise it will not cause a memory lift. In specific situations, the chosen candidate is not suitable as it has later references. For example:
a = alloc()
emr_lift = alloc ()
x = loop (a, emr_lift)
print (x)
free (x)
print (a)
free (a)
here a
is referenced both by the loop and a call to print
. The
return value x
can in this situation be an alias to either a
or
emr_lift
depending on the return criteria of the loop. In the first
case the second free errors out as a
, via x
, has already been freed.
The latter case does not display this problem.
This MR extends FRC (filter reuse candidates) to additionally check
function ERCs, thereby resolving the above example, e.g. emr_lift
would never materialize as a
is referenced twice in the body.