From cf85d51859cdd2688e6d44e3feda88d357b8a52d Mon Sep 17 00:00:00 2001 From: Reini Urban Date: Fri, 28 Feb 2014 10:25:18 -0600 Subject: [PATCH] [imcc] Fixed last remaining -O2 issue #1044 t/pmc/exception-old_19.pir Stop constant propagation at yield or invokecc for possible push_eh/pop_eh non-local effects. This can undo the set of the constant value. See t/pmc/exception-old_19.pir: cont = test() contains a push_eh, and the subsequent pop_eh at cont() changes the value of the constant redux from 0 back to 1. So constant propagation for redux=0 cannot delete "if redux goto done" and the done branch. --- ChangeLog | 53 +++++++++++++++++++++----------------- compilers/imcc/optimizer.c | 9 ++++++- t/pmc/exception-old.t | 10 +++---- 3 files changed, 43 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b1ab75970..8b8e5e180a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,33 +1,40 @@ 2014-03-18 release 6.2.0 - Core - + Re-enable old immc flags for parrot and parrot_old, such as - -On -a -v -y -E -dxx. [GH #1033] - + Fixed imcc -O1. Special-case get_global for branch_cond_loop_swap, - which broke nci tests [GH #1037] - + Fixed imcc for -O2 to allow used_once elimination only for - purely functional ops without side-effects [GH #1036] - + Fixed most imcc -O2 errors in constant propagation - = leading to empty ins->op ptrs when deleting or skipping - certain instruction [GH #1039], - = a wrong logic leading to missed detecting writes - from get_results [GH #1041], - = propagate only matching types in setters [GH #1042], and - = empty ins->next in used_once deletion [GH #1044]. - Only 1 remaining -O2 test regression. + + Re-enable old immc flags for parrot and parrot_old, such as + -On -a -v -y -E -dxx. [GH #1033] + + + Fixed imcc -O1 and -O2. + + -O1 fixes: + = Special-case get_global for branch_cond_loop_swap, which broke nci + tests [GH #1037] + + -O2 used_once fixes: + = Allow used_once elimination only for purely functional ops + without side-effects [GH #1036] + = Empty ins->next in deletion [GH #1042]. + + -O2 constant propagation fixes: + = Empty ins->op ptrs when deleting or skipping certain instruction + [GH #1039], + = Wrong logic leading to missed detecting writes from get_results + [GH #1041], + = Propagate only matching types in setters [GH #1042], + = Stop at yield or invokecc for possible push_eh/pop_eh non-local + effects [GH #1044] - Build - + Set emacs buffer-read-only:t tags in generated files [GH #1034] - + Provide coda for generated include/*.pasm files [GH #1032] - + Fix parser for bison 3 [GH #1031] + + Set emacs buffer-read-only:t tags in generated files [GH #1034] + + Provide coda for generated include/*.pasm files [GH #1032] + + Fix parser for bison 3 [GH #1031] - Deprecations - + Warn on deprecated usage of append_configure_log() + + Warn on deprecated usage of append_configure_log() - Documentation - + Updated pod for parrot and tools/build/c2str.pl + + Updated pod for parrot and tools/build/c2str.pl - Tests - + Added -O1 and -O2 to fulltest - + Mark failing -O2 test + + Added -O1 and -O2 to fulltest - Community - + Got accepted for GSOC. Got a candidate for "Improve performance - of method signatures" + + Parrot has been accepted to Google Summer of Code 2014 + + Got a candidate for "Improve performance of method signatures" 2014-02-18 release 6.1.0 - Build diff --git a/compilers/imcc/optimizer.c b/compilers/imcc/optimizer.c index 0ec4de0aa6..2b48dac459 100644 --- a/compilers/imcc/optimizer.c +++ b/compilers/imcc/optimizer.c @@ -693,7 +693,8 @@ strength_reduce(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) =item C Does conservative constant propagation. -This code will not propagate constants past labels or saves, + +This code will not propagate constants past labels, invokecc, yield or saves, even though sometimes it may be safe. =cut @@ -734,6 +735,10 @@ constant_propagation(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) if (found) { Instruction *ins2; + /* Propagate the constant into all subsequent ops in the same basic block. + But skip on the first write into this constant. + Also skip on invokecc or yield ops, as they can contain pop_eh and + undo the constant value. GH #1044 */ IMCC_debug(imcc, DEBUG_OPT2, "propagating constant %s from ", c->name); IMCC_debug_ins(imcc, DEBUG_OPT2, ins); for (ins2 = ins->next; ins2; ins2 = ins2->next) { @@ -745,6 +750,8 @@ constant_propagation(ARGMOD(imc_info_t *imcc), ARGMOD(IMC_Unit *unit)) IMCC_debug(imcc, DEBUG_OPT2, "\tchecking op "); IMCC_debug_ins(imcc, DEBUG_OPT2, ins2); } + if (ins2->type & ITPCCSUB || ins->type & ITPCCYIELD) + goto next_constant; /* was opsize - 2, changed to n_r - 1 */ for (i = ins2->symreg_count - 1; i >= 0; i--) { if (STREQ(o->name, ins2->symregs[i]->name)) { diff --git a/t/pmc/exception-old.t b/t/pmc/exception-old.t index 9c0fddc1bb..41c6cb0240 100644 --- a/t/pmc/exception-old.t +++ b/t/pmc/exception-old.t @@ -431,16 +431,17 @@ something broke current inst/ OUTPUT -TODO: { - local $TODO = '-O2 t/pmc/exception-old_19.pir regression #1044' - if $ENV{TEST_PROG_ARGS} =~ / -O2/; - pir_output_is(<<'CODE', <<'OUTPUT', "taking a continuation promotes RetCs"); +pir_output_is(<<'CODE', <<'OUTPUT', "taking a continuation promotes RetCs"); ## This test creates a continuation in a inner sub and re-invokes it later. The ## re-invocation signals an error, which is caught by an intermediate sub. ## Returning from the "test" sub the second time failed in r28794; invoking ## parrot with "-D80" shows clearly that the "test" context was being recycled ## prematurely. For some reason, it is necessary to signal the error in order ## to expose the bug. +## See also -O2 t/pmc/exception-old_19.pir regression [GH #1044] +## cont = test() contains a push_eh, and the subsequent pop_eh at cont() changes +## the value of the constant redux from 0 back to 1. So constant propagation for +## redux=0 cannot delete "if redux goto done" and the done branch. .sub main :main .local int redux .local pmc cont @@ -495,7 +496,6 @@ calling cont back from test done. OUTPUT -} pir_error_output_like( <<'CODE', <<'OUTPUT', "throw - no handler" ); .sub main :main