@@ -840,6 +840,24 @@ createProjection(SILBuilder &B, SILLocation Loc, SILValue Arg) const {
840
840
return Proj->createProjection (B, Loc, Arg);
841
841
}
842
842
843
+ // Projection tree only supports structs and tuples today.
844
+ static bool isSupportedProjection (const Projection &p) {
845
+ switch (p.getKind ()) {
846
+ case ProjectionKind::Struct:
847
+ case ProjectionKind::Tuple:
848
+ return true ;
849
+ case ProjectionKind::Class:
850
+ case ProjectionKind::Enum:
851
+ case ProjectionKind::Box:
852
+ case ProjectionKind::Upcast:
853
+ case ProjectionKind::RefCast:
854
+ case ProjectionKind::BitwiseCast:
855
+ case ProjectionKind::TailElems:
856
+ case ProjectionKind::Index:
857
+ return false ;
858
+ }
859
+ }
860
+
843
861
void
844
862
ProjectionTreeNode::
845
863
processUsersOfValue (ProjectionTree &Tree,
@@ -863,12 +881,11 @@ processUsersOfValue(ProjectionTree &Tree,
863
881
continue ;
864
882
}
865
883
866
- // Check whether the user is such a projection.
867
884
auto P = Projection (projectionInst);
868
885
869
- // If we fail to create a projection, add User as a user to this node and
870
- // continue.
871
- if (!P.isValid ()) {
886
+ // If we fail to create a projection or this is a type of projection that we
887
+ // do not support, add User as a user to this node and continue.
888
+ if (!P.isValid () || ! isSupportedProjection (P) ) {
872
889
DEBUG (llvm::dbgs () << " Failed to create projection. Adding "
873
890
" to non projection user!\n " );
874
891
addNonProjectionUser (Op);
0 commit comments