@@ -1069,6 +1069,24 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1069
1069
what + " must be Optional<Builtin.Executor>" );
1070
1070
}
1071
1071
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
+
1072
1090
// / Assert that two types are equal.
1073
1091
void requireSameType (Type type1, Type type2, const Twine &complaint) {
1074
1092
_require (type1->isEqual (type2), complaint,
@@ -5806,10 +5824,21 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
5806
5824
if (HI->getModule ().getStage () == SILStage::Lowered) {
5807
5825
requireOptionalExecutorType (executor,
5808
5826
" 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" );
5809
5832
}
5810
5833
}
5811
5834
5812
5835
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" );
5813
5842
if (EEI->getModule ().getStage () == SILStage::Lowered) {
5814
5843
require (false ,
5815
5844
" extract_executor instruction should have been lowered away" );
0 commit comments