I decided to look into the Yara branch to see if it could even be 
bootstrap on PPC (with Yara turned on by default).


I ran into an ICE while compiling libgcc2.c for __muldi3.
The ICE was in emit_secondary_memory_move.
The preprocessed source is:
typedef int SItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
struct DWstruct {SItype high, low;};
typedef union
{
    struct DWstruct s;
    DItype ll;
} DWunion;
DItype __muldi3 (DItype u)
{
    DWunion w;
    w.ll = 0;
    w.s.high = u;
    return w.ll;
}

---------------------------------------------------------------------------

And then I decided just to look into code generation:
int  f(void)
{
   return 0;
}

---------------------------------------------------------------------------
With the above code, I noticed that GCC saved and restored
the link register which is not needed because this is a leaf function.

The reason why it was being saved/restored is because 
current_function_is_leaf was not being set at all with Yara on.
Before it was being set in the local-alloc.c.

The next code generation issue is related to the ICE above as
both are caused by spilling long long variables to the stack always (or it 
seems).

Also it looks like it might be producing wrong code too as the one half is 
not zero'd out.
Testcase:

typedef int SItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
DItype __muldi3 (DItype u)
{
    DItype ll;
    ll = 0;
    ll = (ll &~0xFFFFFFFF) | (u&0xFFFFFFFF);
   return ll;
}
---------------------------------------------------------------------------
Asm produced WITHOUT Yara turned on:
        .machine ppc
        .text
        .align 2
        .globl ___muldi3
___muldi3:
        li r3,0
        blr
        .subsections_via_symbols

---------------------------------------------------------------------------
Asm produced WITH Yara turned on:
        .machine ppc
        .text
        .align 2
        .globl ___muldi3
___muldi3:
        mflr r0
        stw r0,8(r1)
        stwu r1,-48(r1)
        lwz r0,24(r1)
        stw r4,20(r1)
        stw r0,12(r1)
        lfd f0,8(r1)
        stfd f0,16(r1)
        lwz r3,16(r1)
        lwz r4,20(r1)
        addi r1,r1,48
        lwz r0,8(r1)
        mtlr r0
        blr
        .subsections_via_symbols
---------------------------------------------------------------------------

Hopefully this helps the progress of Yara some more.

Thanks,
Andrew Pinski


Reply via email to