Skip to content

Commit

Permalink
Validate GCM scheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed May 23, 2024
1 parent 2ef87d2 commit e87914b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ir_gcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ static bool ir_split_partially_dead_node(ir_ctx *ctx, ir_ref ref, uint32_t b)
}
#endif

#ifdef IR_DEBUG
static bool ir_gcm_dominates(ir_ctx *ctx, uint32_t b1, uint32_t b2)
{
uint32_t b1_depth = ctx->cfg_blocks[b1].dom_depth;
const ir_block *bb2 = &ctx->cfg_blocks[b2];

while (bb2->dom_depth > b1_depth) {
b2 = bb2->dom_parent;
bb2 = &ctx->cfg_blocks[b2];
}
return b1 == b2;
}
#endif

static void ir_gcm_schedule_late(ir_ctx *ctx, ir_ref ref, uint32_t b)
{
ir_ref n, use;
Expand Down Expand Up @@ -494,6 +508,7 @@ static void ir_gcm_schedule_late(ir_ctx *ctx, ir_ref ref, uint32_t b)
}

IR_ASSERT(lca != 0 && "No Common Ancestor");
IR_ASSERT(ir_gcm_dominates(ctx, ctx->cfg_map[ref], lca) && "Early placement doesn't dominate the late");

#if IR_GCM_SPLIT
if (ctx->use_lists[ref].count > 1
Expand Down

0 comments on commit e87914b

Please sign in to comment.