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