[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] miscompilation: save/restore of clobbered registers

From: Jeyasankar Kottalam
Subject: [avr-gcc-list] miscompilation: save/restore of clobbered registers
Date: Mon, 11 Jul 2005 14:43:36 -0700
User-agent: Internet Messaging Program (IMP) H3 (4.0)


With GCC 3.4.4 and 4.0.0 the following code is miscompiled; registers that the
function modifies are not saved and restored when entering/leaving the
function. We worked around the issue by adding explicit pushes and pops of
registers r16 through r19 in our code.

typedef unsigned char u1;
typedef unsigned long u4;

u4 sram_read_u4( u1 *ptr )
    return (((u4) *ptr) << 24)
         | (((u4) *(ptr + 1)) << 16)
         | (((u4) *(ptr + 2)) << 8)
         | (((u4) *(ptr + 3)));

I've attached the output of GCC 4.0.0 with "-mmcu=atmega128", but the problem is
 present in 3.4.4 as well, and also present with or without optimization.

I briefly looked into the problem and it looks like the problem lies in
avr_regs_to_save() determining which registers should be saved and restored by
the prologue/epilogue.

-Jey Kottalam

reply via email to

[Prev in Thread] Current Thread [Next in Thread]