[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] Code that fails to compile with any optimization enabled
From: |
Dave Hylands |
Subject: |
[avr-gcc-list] Code that fails to compile with any optimization enabled |
Date: |
Fri, 20 Apr 2007 13:45:21 -0700 |
Hi,
The following code snippet (as small as I could get it and still
reproduce the problem) fails to compile with the following command
line:
avr-gcc -c -mmcu=atmega168 ee-fail.c -Os
Dropping the -Os or using -O0 makes it work. Using -O1 -O2 -O3 or -Os
all cause the following errors:
606 >avr-gcc -c -mmcu=atmega168 ee-fail.c -O3
ee-fail.c: In function 'build_pwm_table':
c:/winavr/bin/../avr/include/avr/eeprom.h:208: error: can't find a
register in class 'BASE_POINTER_REGS' while reloading 'asm'
c:/winavr/bin/../avr/include/avr/eeprom.h:208: error: can't find a
register in class 'BASE_POINTER_REGS' while reloading 'asm'
Removing the second call to fill_pwm_table also allows things to work
with all optimization levels.
I figured I'd post to the list to discuss before filing a bug report.
#include <avr/eeprom.h>
uint8_t pwm_tab_1 [126];
static uint16_t ee_chan_1_min EEMEM = 140,
ee_chan_1_cent EEMEM = 188,
ee_chan_1_max EEMEM = 240,
ee_chan_1_forw_min EEMEM = 20,
ee_chan_1_forw_max EEMEM = 90,
ee_chan_1_back_max EEMEM = 80;
void fill_pwm_table (int8_t chan_num, uint8_t pwm [], int16_t forward_max,
int16_t center, int16_t reverse_min, int16_t forward_high,
int16_t forward_low, int16_t reverse_high );
void build_pwm_table (void)
{
int16_t center_1,
forward_max_1,
reverse_min_1,
forward_high_1,
forward_low_1,
reverse_high_1;
center_1 = eeprom_read_word (&ee_chan_1_cent);
forward_max_1 = eeprom_read_word (&ee_chan_1_max);
reverse_min_1 = eeprom_read_word (&ee_chan_1_min);
forward_high_1 = eeprom_read_word (&ee_chan_1_forw_max);
forward_low_1 = eeprom_read_word (&ee_chan_1_forw_min);
reverse_high_1 = eeprom_read_word (&ee_chan_1_back_max);
fill_pwm_table (1, pwm_tab_1, forward_max_1, center_1, reverse_min_1,
forward_high_1, forward_low_1, reverse_high_1);
fill_pwm_table (1, pwm_tab_1, forward_max_1, center_1, reverse_min_1,
forward_high_1, forward_low_1, reverse_high_1);
}
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
- [avr-gcc-list] Code that fails to compile with any optimization enabled,
Dave Hylands <=