Permalink
Browse files

[imcc] WIP attempt to fix #1039

but the ins->op (the op ptr) appears now later in emit_pbc
  • Loading branch information...
1 parent 2ac3fbf commit 104966bf4faaad62e0715902c348c3610a79af17 Reini Urban committed Feb 27, 2014
Showing with 25 additions and 19 deletions.
  1. +11 −7 compilers/imcc/optimizer.c
  2. +14 −12 compilers/imcc/pbc.c
View
@@ -768,18 +768,22 @@ constant_propagation(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit))
tmp = IMCC_subst_constants(imcc,
unit, ins2->opname, ins2->symregs, ins2->opsize,
&found);
- if (found && tmp) { /* XXX syn/clash_1.pir */
+ if (found) {
const Instruction * const prev = ins2->prev;
if (prev) {
- subst_ins(unit, ins2, tmp, 1);
+ if (tmp) /* see syn/clash_1.pir */
+ subst_ins(unit, ins2, tmp, 1);
any = 1;
- IMCC_debug(imcc, DEBUG_OPT2, " reduced to ");
- IMCC_debug_ins(imcc, DEBUG_OPT2, tmp);
+ if (tmp) {
+ IMCC_debug(imcc, DEBUG_OPT2, " reduced to ");
+ IMCC_debug_ins(imcc, DEBUG_OPT2, tmp);
+ }
+ else {
+ --old->use_count;
+ IMCC_debug(imcc, DEBUG_OPT2, " deleted\n");
+ }
ins2 = prev->next;
}
- if (!ins2->op) {
- IMCC_debug(imcc, DEBUG_OPT2, " no op!\n");
- }
}
else {
char fullname[128];
View
@@ -693,20 +693,22 @@ get_code_size(ARGMOD(imc_info_t * imcc), ARGIN(const IMC_Unit *unit),
continue;
}
(*src_lines)++;
- if (!ins->op)
- IMCC_fatal(imcc, 1, "get_code_size: "
- "no opnum ins#%d 0x%x\n",
- ins->index, ins);
-
- if (ins->op == &core_ops->op_info_table[PARROT_OP_set_p_pc]) {
- /* set_p_pc opcode */
- IMCC_debug(imcc, DEBUG_PBC_FIXUP, "PMC constant %s\n",
- ins->symregs[1]->name);
-
- if (ins->symregs[1]->usage & U_FIXUP)
- store_fixup(imcc, ins->symregs[1], code_size, 2);
+ if (!ins->op) { /* caused by constant propagation */
+ if (!(imcc->debug & DEBUG_OPT2))
+ IMCC_fatal(imcc, 1, "get_code_size: "
+ "no opnum ins#%d 0x%x\n",
+ ins->index, ins);
}
+ else {
+ if (ins->op == &core_ops->op_info_table[PARROT_OP_set_p_pc]) {
+ /* set_p_pc opcode */
+ IMCC_debug(imcc, DEBUG_PBC_FIXUP, "PMC constant %s\n",
+ ins->symregs[1]->name);
+ if (ins->symregs[1]->usage & U_FIXUP)
+ store_fixup(imcc, ins->symregs[1], code_size, 2);
+ }
+ }
code_size += opsize;
}

0 comments on commit 104966b

Please sign in to comment.