Commit Graph

1 Commits

Author SHA1 Message Date
Kavon Farvardin
c6686dd8b6 fix for SR-15789
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.
2022-02-03 11:47:29 -07:00