You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add IOState to MallocOperation #1492 added an IOState to the MallocOperation to prevent hoisting. The same issue technically also applies to AllocaOperation, but I would really like to avoid sequentializing allocas with IO.
The AllocaOperation and MallocOperation has hacky implementations of operator ==() to prevent Common Node Elimination from collapsing distinct alloca nodes into a single node.
What I mean by "unique per invocation" is that two instances of the operation produce unique results, even if they take identical inputs. This is what effectively happens with alloca and malloc. Marking an operation as unique would disable Common Node Elimination, and prevent hoisting out of loops (as each iteration has its own invocation of the operation). Hoisting out of gamma nodes is still fine, assuming all regions contain the operation, as the total number of invocations does not change.
The only other way I see to represent this in current RVSDG is to route states through the operations, but this has the downside of also forcing the operations to be sequentialized. The state also needs to come from somewhere, and it should not be the IO state. Routing states also entail special handling when doing Dead Node Elimination, as the state should not be able to keep the operation alive.
What do you think about having such a "trait" on operations, @caleridas? In practice it would be a virtual method on the Operation class.
Is there a name for operations that only have the side-effect of producing a unique result each time, but otherwise being "stateless"?
I think it makes sense to define a clear way for operations to mark themselves as "unique per invocation".
This comes up after considering the following:
MallocOperationto prevent hoisting. The same issue technically also applies toAllocaOperation, but I would really like to avoid sequentializing allocas with IO.AllocaOperationandMallocOperationhas hacky implementations ofoperator ==()to prevent Common Node Elimination from collapsing distinct alloca nodes into a single node.What I mean by "unique per invocation" is that two instances of the operation produce unique results, even if they take identical inputs. This is what effectively happens with alloca and malloc. Marking an operation as unique would disable Common Node Elimination, and prevent hoisting out of loops (as each iteration has its own invocation of the operation). Hoisting out of gamma nodes is still fine, assuming all regions contain the operation, as the total number of invocations does not change.
The only other way I see to represent this in current RVSDG is to route states through the operations, but this has the downside of also forcing the operations to be sequentialized. The state also needs to come from somewhere, and it should not be the IO state. Routing states also entail special handling when doing Dead Node Elimination, as the state should not be able to keep the operation alive.
What do you think about having such a "trait" on operations, @caleridas? In practice it would be a virtual method on the
Operationclass.Is there a name for operations that only have the side-effect of producing a unique result each time, but otherwise being "stateless"?