(I'm reposting this because I'm not sure what happened to the one that I sent to parrotbugs; forgive me if two eventually appear)

Folks,

There seems to be some problems with -O1 when instructions are optimised at the end of functions. For instance, take

sub main
  func ()
end

sub func
  $I0 += 1
end

which translates to

main:
@pcc_sub_call_0:
        set I0, 1
        set I1, 0
        set I2, 0
        set I3, 0
        set I4, 0
        set S1, ""
        set_p_pc P0, func
        invokecc
        null I0
        null I3
        returncc
func:
        add I30, 1
        null I0
        null I3
        returncc

When optimised with -O1 you instead get

main:
@pcc_sub_call_0:
        set I0, 1
        set I1, 0
        set I2, 0
        set I3, 0
        set I4, 0
        set S1, ""
        set_p_pc P0, func
        invokecc
        null I0
        null I3
        returncc
func:
        inc I30

where the tail of func is lost after the instruction has been substituted (and as such core dumps for me as control goes past the end of the bytecode).

In what is semi-related to this, if a deleted instruction (e.g. $I0+=0) is at the end of a function, you get a core dump in imcc/optimiser.c in this line (because ins is NULL):

 ins = ins->prev ? ins->prev : unit->instructions;

If no ones picked this up in the next couple of days, I'll hopefully have time to get my teeth into it...

Cheers,

Nick

Reply via email to