Skip to content

[projection] Add non-supported projection users to the non projection… #17365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions lib/SIL/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,24 @@ createProjection(SILBuilder &B, SILLocation Loc, SILValue Arg) const {
return Proj->createProjection(B, Loc, Arg);
}

// Projection tree only supports structs and tuples today.
static bool isSupportedProjection(const Projection &p) {
switch (p.getKind()) {
case ProjectionKind::Struct:
case ProjectionKind::Tuple:
return true;
case ProjectionKind::Class:
case ProjectionKind::Enum:
case ProjectionKind::Box:
case ProjectionKind::Upcast:
case ProjectionKind::RefCast:
case ProjectionKind::BitwiseCast:
case ProjectionKind::TailElems:
case ProjectionKind::Index:
return false;
}
}

void
ProjectionTreeNode::
processUsersOfValue(ProjectionTree &Tree,
Expand All @@ -866,12 +884,11 @@ processUsersOfValue(ProjectionTree &Tree,
continue;
}

// Check whether the user is such a projection.
auto P = Projection(projectionInst);

// If we fail to create a projection, add User as a user to this node and
// continue.
if (!P.isValid()) {
// If we fail to create a projection or this is a type of projection that we
// do not support, add User as a user to this node and continue.
if (!P.isValid() || !isSupportedProjection(P)) {
DEBUG(llvm::dbgs() << " Failed to create projection. Adding "
"to non projection user!\n");
addNonProjectionUser(Op);
Expand Down