@@ -1069,6 +1069,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
10691069 what + " must be Optional<Builtin.Executor>" );
10701070 }
10711071
1072+ // / Require the operand to be an object of some type that conforms to
1073+ // / Actor or DistributedActor.
1074+ void requireAnyActorType (SILValue value, bool allowOptional,
1075+ bool allowExecutor, const Twine &what) {
1076+ auto type = value->getType ();
1077+ require (type.isObject (), what + " must be an object type" );
1078+
1079+ auto actorType = type.getASTType ();
1080+ if (allowOptional) {
1081+ if (auto objectType = actorType.getOptionalObjectType ())
1082+ actorType = objectType;
1083+ }
1084+ if (allowExecutor && isa<BuiltinExecutorType>(actorType))
1085+ return ;
1086+ require (actorType->isAnyActorType (),
1087+ what + " must be some kind of actor type" );
1088+ }
1089+
10721090 // / Assert that two types are equal.
10731091 void requireSameType (Type type1, Type type2, const Twine &complaint) {
10741092 _require (type1->isEqual (type2), complaint,
@@ -5806,10 +5824,21 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58065824 if (HI->getModule ().getStage () == SILStage::Lowered) {
58075825 requireOptionalExecutorType (executor,
58085826 " hop_to_executor operand in lowered SIL" );
5827+ } else {
5828+ requireAnyActorType (executor,
5829+ /* allow optional*/ true ,
5830+ /* allow executor*/ true ,
5831+ " hop_to_executor operand" );
58095832 }
58105833 }
58115834
58125835 void checkExtractExecutorInst (ExtractExecutorInst *EEI) {
5836+ requireObjectType (BuiltinExecutorType, EEI,
5837+ " extract_executor result" );
5838+ requireAnyActorType (EEI->getExpectedExecutor (),
5839+ /* allow optional*/ false ,
5840+ /* allow executor*/ false ,
5841+ " extract_executor operand" );
58135842 if (EEI->getModule ().getStage () == SILStage::Lowered) {
58145843 require (false ,
58155844 " extract_executor instruction should have been lowered away" );
0 commit comments