Skip to content

Commit

Permalink
Handle non-merge case of PHI
Browse files Browse the repository at this point in the history
Sometimes we end up with a PHI that only actually has one soure to
merge. In this case, we can track allocations through it.

These show up when a call is inlined, since the return value is always
put through a PHI (as part of handling multiple returns consistently).
Thus this means we can now handle some simple cases of eliminating an
allocation that is made in one routine and immediately got rid of in
another.
  • Loading branch information
jnthn committed Oct 9, 2018
1 parent e65ce59 commit 15ab517
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/spesh/pea.c
Expand Up @@ -474,10 +474,21 @@ static MVMuint32 analyze(MVMThreadContext *tc, MVMSpeshGraph *g, GraphState *gs)
break;
}
case MVM_SSA_PHI: {
/* For now, don't handle these. */
MVMuint32 i = 0;
for (i = 1; i < ins->info->num_operands; i++)
real_object_required(tc, g, ins, ins->operands[i]);
/* If a PHI doesn't really merge anything, and its input is
* a tracked object, we just alias the output. */
MVMuint16 num_operands = ins->info->num_operands;
if (num_operands == 2) {
MVMSpeshFacts *source = MVM_spesh_get_facts(tc, g, ins->operands[1]);
MVMSpeshPEAAllocation *alloc = source->pea.allocation;
if (allocation_tracked(alloc))
MVM_spesh_get_facts(tc, g, ins->operands[0])->pea.allocation = alloc;
}
else {
/* Otherwise, don't handle these for now. */
MVMuint32 i = 0;
for (i = 1; i < ins->info->num_operands; i++)
real_object_required(tc, g, ins, ins->operands[i]);
}
break;
}
default: {
Expand Down

0 comments on commit 15ab517

Please sign in to comment.