Skip to content
Merged
Prev Previous commit
Next Next commit
move a few things around
  • Loading branch information
iritkatriel committed Sep 29, 2022
commit 103c9ae910854d9bd6c9e21104e8fdf254ec4165
18 changes: 11 additions & 7 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -8628,10 +8628,7 @@ assemble(struct compiler *c, int addNone)
}
nlocalsplus -= numdropped;

consts = consts_dict_keys_inorder(c->u->u_consts);
if (consts == NULL) {
goto error;
}
/** Desugaring **/
Comment thread
iritkatriel marked this conversation as resolved.
Outdated
if (calculate_jump_targets(g->g_entryblock)) {
goto error;
}
Expand All @@ -8641,6 +8638,12 @@ assemble(struct compiler *c, int addNone)
if (label_exception_targets(g->g_entryblock)) {
goto error;
}

/** Optimization **/
consts = consts_dict_keys_inorder(c->u->u_consts);
if (consts == NULL) {
goto error;
}
if (optimize_cfg(g, consts, c->c_const_cache)) {
goto error;
}
Expand All @@ -8665,6 +8668,7 @@ assemble(struct compiler *c, int addNone)
remove_redundant_nops(b);
}

/** Assembly **/
/* Order of basic blocks must have been determined by now */
if (normalize_jumps(g) < 0) {
goto error;
Expand Down Expand Up @@ -9599,12 +9603,14 @@ is_exit_without_lineno(basicblock *b) {
static int
duplicate_exits_without_lineno(cfg_builder *g)
{
assert(no_empty_basic_blocks(g));
/* Copy all exit blocks without line number that are targets of a jump.
*/
basicblock *entryblock = g->g_entryblock;
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
struct instr *last = basicblock_last_instr(b);
if (last != NULL && is_jump(last)) {
assert(last != NULL);
if (is_jump(last)) {
basicblock *target = last->i_target;
if (is_exit_without_lineno(target) && target->b_predecessors > 1) {
basicblock *new_target = copy_basicblock(g, target);
Expand All @@ -9621,8 +9627,6 @@ duplicate_exits_without_lineno(cfg_builder *g)
}
}

assert(no_empty_basic_blocks(g));

/* Any remaining reachable exit blocks without line number can only be reached by
* fall through, and thus can only have a single predecessor */
for (basicblock *b = entryblock; b != NULL; b = b->b_next) {
Expand Down