Skip to content

Commit 2ee56f8

Browse files
committed
Handle Builtin.Executor types in lowering
LowerHopToActor expected either an optional executor or an actor, and would crash when given a non-optional executor. This patch adds the wrapping to produce an optional executor from a non-optional executor in the pass to avoid crashing.
1 parent 377ca35 commit 2ee56f8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/SILOptimizer/Mandatory/LowerHopToActor.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,19 @@ bool LowerHopToActor::processHop(HopToExecutorInst *hop) {
102102
B.setInsertionPoint(hop);
103103
B.setCurrentDebugScope(hop->getDebugScope());
104104

105-
// Get the dominating executor value for this actor, if available,
106-
// or else emit code to derive it.
107-
SILValue executor = emitGetExecutor(hop->getLoc(), actor, /*optional*/true);
105+
SILValue executor;
106+
if (actor->getType().is<BuiltinExecutorType>()) {
107+
// IRGen expects an optional Builtin.Executor, not a Builtin.Executor
108+
// but we can wrap it nicely
109+
executor = B.createOptionalSome(
110+
hop->getLoc(), actor,
111+
SILType::getOptionalType(actor->getType()));
112+
} else {
113+
// Get the dominating executor value for this actor, if available,
114+
// or else emit code to derive it.
115+
executor = emitGetExecutor(hop->getLoc(), actor, /*optional*/true);
116+
}
117+
assert(executor && "executor not set");
108118

109119
B.createHopToExecutor(hop->getLoc(), executor, /*mandatory*/ false);
110120

0 commit comments

Comments
 (0)