Closed Feliix42 closed 5 years ago
The problem is that we always create a ctrl
assuming that we always need to context a variable or independent function. This is only true for conditionals because these do not have an input, i.e., the branches themselves are independent functions. This is not true for smap
and recur
.
The right thing to do is to alter the transformations for both of these constructs in such a way that they do not produce a ctrl
when there is nothing to be contexted. This is trivial but has a little twist: smapFun
and recur
always have an output arc for the ctrl
. If we do not create a ctrl
then the versions of smapFun
and recur
must also change, i.e., to versions without this ctrl
. This would require to implement them twice at the backend and would probably lead to code duplication.
That's why we might want to consider leaving the concept of DeadEndArcs
in and only make sure that we do not create the ctrl
.
Comments, opinions?
I agree with your view that the ctrl
operator in question should not be created but the concept of DeadEndArcs
should be retained. This allows for a rather smooth fix that avoids unnecessary duplicate code and is probably the easiest to implement.
I think I fixed it and I'll close the issue. Should more problems arise feel free to reopen
I'm pretty sure the problems with unused ctrl
args are done.
However a related issue has arisen, which I am now tracking with #33
The current version of
ohua-core
(cab3ff9ee43fa3fb6dedff7c869345c9026805e5) and I think the current version from master as well produce an unnecessaryctrl
operator for this simple smap algorithm:This leads to the problem that incorrect code is being generated for the
ctrl
operator, as there is nothing to context. The current workaround is that the backend contains an optimization pass that identifies thesectrl
operators and removes them, leaving behind aDeadEndArc
that just discards all inputs. But as @sertel pointed out it would be wiser to do this in an earlier step incore
.alang-resolved|dflang-initial|dflang-core