Code generation problem with gcc-4.6.1

David Kastrup dak@gnu.org
Sun Nov 27 18:36:00 GMT 2011


David Kastrup <dak@gnu.org> writes:

> David Kastrup <dak@gnu.org> writes:
>
> P.S.:
>
>> A workaround has been compiling with the options
>>
>> -fkeep-inline-functions -fno-crossjumping
>>
>> I don't know which of the two options is responsible for avoiding the
>> problem but can test if it makes a difference to you.
>
> It is -fkeep-inline-functions that does the trick.  The generated code
> does not generate a _jump_ to Grob::internal_set_property in this case
> (for whatever fuzzy reason), but rather a _call_, and with the right
> parameters.
>
> Compilation options I forgot to mention are -O2 -fwrapv.  Unfortunately,
> an attempt of extracting a toy version of this bug (by taking the
> original code and replacing all relevant calls and structures with dummy
> declarations in a similar spirit) has not been successful so far, as the
> generated code of the toy version is ok even when jumping instead of
> calling.
>
> So the problem appears to trigger only under quite specific conditions.

-fwrapv is not necessary, just -O2 is enough.

I append a semi-preprocessed file (I removed all of the system headers
and cut out lots of crap before getting tired) that calls for libguile
as well (including the headers of those would have been too much).

As I said: the code generated for
Tab_staff_symbol_engraver::acknowledge_staff_symbol (Grob_info gi)
is the problem, namely its call to
Grob::internal_set_property
where it confuses the second argument with `this', generating the code:

        movl    %ebx, 40(%esp)
        movl    %ebx, 32(%esp)
        movl    %eax, 36(%esp)
        addl    $24, %esp
        .cfi_remember_state
        .cfi_def_cfa_offset 8
        popl    %ebx
        .cfi_def_cfa_offset 4
        .cfi_restore 3
        jmp     _ZN4Grob21internal_set_propertyEP17scm_unused_structS1_

Can you take it from there?

Thanks

-------------- next part --------------
A non-text attachment was scrubbed...
Name: junk.cc
Type: text/x-c++src
Size: 25397 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20111127/5f2f63c4/attachment.bin>
-------------- next part --------------

-- 
David Kastrup


More information about the Gcc-bugs mailing list