Although they currently have MemoryBehavior::MayHaveSideEffects, the
begin_borrow and end_borrow instructions do not have side-effects of
interest to this pass.
The problem is in `OptimizeHopToExecutor::collectActors`, which is
causing `removeRedundantHopToExecutors` to drop the `hop_to_executor`. The issue
is triggered by the order in which the Actors map is populated, and the reuse
of a SILValue representing an executor. Suppose we have a function like this:
```
bb0:
%7 = builtin "getCurrentExecutor"() : $Optional<Builtin.Executor>
// ...
cond_br %12, bb2, bb1
bb1:
// ...
hop_to_executor %7 : $Optional<Builtin.Executor>
bb2:
// ...
hop_to_executor %7 : $Optional<Builtin.Executor>
// ...
hop_to_executor %28 : $MainActor
```
Since `collectActors` goes through each function's instructions top-down,
and assigns to each unique SILValue an ID equal to the size of the Actors map
prior to inserting the SILValue in the map, and we end up with the wrong actor IDs.
This commit changes the ID numbering scheme to correct the issue.
SILGen this builtin to a mandatory hop_to_executor with an actor type
operand.
e.g.
Task.detached {
Builtin.hopToActor(MainActor.shared)
await suspend()
}
Required to fix a bug in _runAsyncMain.
And rename MemoryDataflow -> BitDataflow.
MemoryLifetime contained MemoryLocations, MemoryDataflow and the MemoryLifetimeVerifier.
Three independent things, for which it makes sense to have them in three separated files.
NFC.
* Redundant hop_to_executor elimination: if a hop_to_executor is dominated by another hop_to_executor with the same operand, it is eliminated:
hop_to_executor %a
... // no suspension points
hop_to_executor %a // can be eliminated
* Dead hop_to_executor elimination: if a hop_to_executor is not followed by any code which requires to run on its actor's executor, it is eliminated:
hop_to_executor %a
... // no instruction which require to run on %a
return
rdar://problem/70304809