Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

-O2 t/pmc/exception-old_19.pir regression #1044

Closed
rurban opened this Issue · 1 comment

1 participant

@rurban
Collaborator
$ ./parrot -d7161 -O2 t/pmc/exception-old_19.pir
debug = 0x7161, optim = 0x3
Reading t/pmc/exception-old_19.pir
opt1 0xcbd032e0 set redux, 0
  => 0xcbd03f30 null redux
propagating constant 0xcbd03f30 null redux
    checking op 0xcbd03420 print "calling test\n"
    checking op 0xcbd03610  @pcc_sub_call_0:
    checking op 0xcbd041f0 set_args
    checking op 0xcbd04170 set_p_pc __imcc_temp_2, test
    checking op 0xcbd04270 invokecc __imcc_temp_2
    checking op 0xcbd04380 get_results
    checking op 0xcbd03770 print "back from test\n"
    checking op 0xcbd03870 if redux, done
 checking register 0 0xcbd03870 if redux, done
    propagating into register 0: 0xcbd03870 if redux, done
opt if_xc_ic => deleted
 deleted 0xcbd03870 if 0, done
propagating constant 0xcbd03970 set redux, 1
    checking op 0xcbd03ab0 print "calling cont\n"
    checking op 0xcbd03c20  @pcc_sub_call_1:
    checking op 0xcbd04430 set_args
    checking op 0xcbd044b0 invokecc cont
    checking op 0xcbd04530 get_results
    checking op 0xcbd03d30 print "never.\n"
block 1 label done deleted
propagating constant 0xcbd03f30 null redux
    checking op 0xcbd03420 print "calling test\n"
    checking op 0xcbd03610  @pcc_sub_call_0:
    checking op 0xcbd041f0 set_args
    checking op 0xcbd04170 set_p_pc __imcc_temp_2, test
    checking op 0xcbd04270 invokecc __imcc_temp_2
    checking op 0xcbd04380 get_results
    checking op 0xcbd03770 print "back from test\n"
    checking op 0xcbd03970 set redux, 1
 checking register 0 0xcbd03970 set redux, 1
propagating constant 0xcbd03970 set redux, 1
    checking op 0xcbd03ab0 print "calling cont\n"
    checking op 0xcbd03c20  @pcc_sub_call_1:
    checking op 0xcbd04430 set_args
    checking op 0xcbd044b0 invokecc cont
    checking op 0xcbd04530 get_results
    checking op 0xcbd03d30 print "never.\n"
    checking op 0xcbd03ec0 print "done.\n"
    checking op 0xcbd032e0 set_returns
    checking op 0xcbd04030 returncc
sub main:
    registers in .pir:   I1, N0, S0, P1
    1 labels, 2 lines deleted, 0 if_branch, 0 branch_branch
    0 branch_cond_loop
    0 used once deleted
    0 invariants_moved
    registers needed:    I1, N0, S0, P2
    registers in .pasm:  I1, N0, S0, P2 - 1
    1 basic_blocks, 0 edges
PMC constant test
code_size(ops) 34  old_size 0
const "calling cont\n"  color 0 use_count 1
const "calling test\n"  color 1 use_count 1
const 0 color 0 use_count 2
const 1 color 1 use_count 1
const "done.\n" color 2 use_count 1
PMC const "(0x0002)"    color 0
const "(0x0002)"    color 0 use_count 1
const "never.\n"    color 3 use_count 1
PMC const "()"  color 1
const "()"  color 1 use_count 4
const "back from test\n"    color 4 use_count 1
add_const_pmc_sub 'main' flags 10 color 2 (Sub) lex_info no :outer(*none*)
0 null_i 0  0xcbd03f30 null I0
2 print_sc 1    0xcbd03420 print "calling test\n"
4 set_args_pc 1 0xcbd041f0 set_args
6 set_p_pc 0 0  0xcbd04170 set_p_pc P0, test
9 invokecc_p 0  0xcbd04270 invokecc P0
11 get_results_pc 0 1   0xcbd04380 get_results
14 print_sc 4   0xcbd03770 print "back from test\n"
16 set_i_ic 0 1 0xcbd03970 set I0, 1
19 print_sc 0   0xcbd03ab0 print "calling cont\n"
21 set_args_pc 1    0xcbd04430 set_args
23 invokecc_p 1 0xcbd044b0 invokecc P1
25 get_results_pc 1 0xcbd04530 get_results
27 print_sc 3   0xcbd03d30 print "never.\n"
29 print_sc 2   0xcbd03ec0 print "done.\n"
31 set_returns_pc 1 0xcbd032e0 set_returns
33 returncc 0xcbd04030 returncc
sub test:
    registers in .pir:   I0, N0, S0, P1
    0 labels, 0 lines deleted, 0 if_branch, 0 branch_branch
    0 branch_cond_loop
    0 used once deleted
    0 invariants_moved
    registers needed:    I0, N0, S0, P2
    registers in .pasm:  I0, N0, S0, P2 - 1
    3 basic_blocks, 3 edges
PMC constant foo
code_size(ops) 27  old_size 34
const "  test:  caught error\n" color 9 use_count 1
const "  calling foo\n" color 10 use_count 1
const "  returning from test.\n"    color 11 use_count 1
add_const_pmc_sub 'test' flags 0 color 3 (Sub) lex_info no :outer(*none*)
branch label at pc 0 addr 20 handle_errs 20
0 push_eh_ic    0xcbd05400 push_eh handle_errs
2 print_sc 10   0xcbd054e0 print "  calling foo\n"
4 set_args_pc 1 0xcbd06010 set_args
6 set_p_pc 1 0  0xcbd05f90 set_p_pc P1, foo
9 invokecc_p 1  0xcbd06090 invokecc P1
11 get_results_pc 0 0   0xcbd06110 get_results
14 print_sc 11  0xcbd05870 print "  returning from test.\n"
16 set_returns_pc 0 0   0xcbd06190 set_returns
19 returncc 0xcbd06210 returncc
20 pop_eh   0xcbd05af0 pop_eh
21 print_sc 9   0xcbd05c30 print "  test:  caught error\n"
23 set_returns_pc 0 0   0xcbd062c0 set_returns
26 returncc 0xcbd06340 returncc
sub foo:
    registers in .pir:   I0, N0, S0, P2
    0 labels, 0 lines deleted, 0 if_branch, 0 branch_branch
    0 branch_cond_loop
    0 used once deleted
    0 invariants_moved
    registers needed:    I0, N0, S0, P2
    registers in .pasm:  I0, N0, S0, P2 - 2
    3 basic_blocks, 3 edges
code_size(ops) 22  old_size 61
const 'Continuation'    color 13 use_count 1
const "    got over there.\n"   color 14 use_count 1
const "    returning from foo\n"    color 15 use_count 1
const 'Exception'   color 16 use_count 1
const 'Continuation'    color 13 use_count 1
const 'Exception'   color 16 use_count 1
add_const_pmc_sub 'foo' flags 0 color 6 (Sub) lex_info no :outer(*none*)
0 new_p_pc 0 4  0xcbd06f80 new P0, ['Continuation']
branch label at pc 3 addr 12 over_there 9
3 set_label_p_ic 0  0xcbd07060 set_label P0, over_there
6 print_sc 15   0xcbd07180 print "    returning from foo\n"
8 set_returns_pc 0 0    0xcbd079a0 set_returns
11 returncc 0xcbd07a20 returncc
12 print_sc 14  0xcbd074b0 print "    got over there.\n"
14 new_p_pc 1 5 0xcbd07750 new P1, ['Exception']
17 throw_p 1    0xcbd077d0 throw P1
19 set_returns_pc 1 0xcbd07850 set_returns
21 returncc 0xcbd078c0 returncc
fixup const PMC sub 'test' const nr: 3
fixup const PMC sub 'foo' const nr: 6
1 lines compiled.
calling test
  calling foo
    returning from foo
  returning from test.
back from test
calling cont
    got over there.
  test:  caught error
back from test
calling cont
    got over there.
No exception handler and no message
current instr.: 'foo' pc 78 (t/pmc/exception-old_19.pir:47)
called from Sub 'test' pc 60 (t/pmc/exception-old_19.pir:34)
called from Sub 'main' pc 25 (t/pmc/exception-old_19.pir:18)
@rurban rurban self-assigned this
@rurban rurban referenced this issue from a commit
@rurban rurban [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.
cf85d51
@rurban rurban closed this
@rurban
Collaborator

Fixed with commit cf85d51
Author: Reini Urban rurban@cpanel.net
Date: Fri Feb 28 10:25:18 2014 -0600

[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.

Once can think of a further -O3 optimization (together with more constant folding)
to check for push_eh and pop_eh in any subsequent ops even across function
call boundaries, and allow propagation if not found.

@rurban rurban reopened this
@rurban rurban closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.