[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?
From: |
Stu Bell |
Subject: |
RE: [avr-gcc-list] Re: optimizer removes volatile pin access code. why? |
Date: |
Wed, 28 Oct 2009 11:49:57 -0600 |
David Brown wrote:
> And an __attribute_((always_inline)) function will be
> inlined, regardless of the optimisation levels.
Sorry, compiler breath -- this is not always true. If you call an
"always_inline" function from inside another "always_inline" function,
with optimization turned off, the compiler throws a fit.
Example -- WinAVR 20090313, file compiled with -O0. Inline function is:
static void
FcsStartUtilTimer( uint16_t Wait ) __attribute__((always_inline));
static void
FcsStartUtilTimer( uint16_t Wait )
{
/* Shut the timer down, make sure interrupts are all off */
UTL_TIMER_TCCRA = 0;
UTL_TIMER_TCCRB = 0;
UTL_TIMER_TIMSK = 0;
/* Set the wait into the counter - this value must be pre-computed
* using the WAIT_TIMER_US_TO_TCNT macro!
*/
UTL_TIMER_TCNT = Wait;
/* set up the utility timer:
* Source clock: System clock / 1
* Mode: Normal
* Output: none
* Interrupt: on nothing
*/
UTL_TIMER_TCCRA = 0;
UTL_TIMER_TCCRB = ( UTL_TIMER_CS0 );
/* Clear the overflow flag */
UTL_TIMER_TIFR = UTL_TIMER_TOVF;
}
And is used as:
static bool
FcsAcquireLookForSumOKDeassert( void ) __attribute__((always_inline));
static bool
FcsAcquireLookForSumOKDeassert( void )
{
/* Wait for SumOK to deassert */
while ( ( FCS_SUMOK_PIN & FCS_SUMOK_H )
&& ! g_DacRampCompleteFlag
)
{
/* Delay for 1uS (use _delay_loop_1 so optimization does not
affect this) */
_delay_loop_1( FCS_GENERIC_1uS_LOOP_WAIT );
}
/* Set up debounce */
FcsStartUtilTimer( WAIT_TIMER_US_TO_TCNT(
FCS_SIGNAL_DEASSERT_DEBOUNCE ) );
/* Debounce SumOK */
while ( ! ( UTL_TIMER_TIFR & UTL_TIMER_TOVF )
&& ! g_DacRampCompleteFlag
)
{
if ( FCS_SUMOK_PIN & FCS_SUMOK_H )
{
/* HMMMMmmm.. Went high - reset the counter */
FcsResetUtilTimer( WAIT_TIMER_US_TO_TCNT(
FCS_SIGNAL_DEASSERT_DEBOUNCE ) );
}
}
return (! g_DacRampCompleteFlag);
}
Returns the following error:
CmdFocus.c: In function 'FcsAcquireLookForSumOKDeassert':
CmdFocus.c:4020: sorry, unimplemented: inlining failed in call to
'FcsStartUtilTimer': function body not available
CmdFocus.c:4152: sorry, unimplemented: called from here
...
The above code compiles fine if the optimizer is turned on (-Os). Of
course, I guess the real question (which I have not investigated) is
whether it compiles *correctly* with -Os. :-/ It functions correctly,
so I presume it is inlining correctly.
Best regards,
Stu Bell
DataPlay (DPHI, Inc.)
- [avr-gcc-list] optimizer removes volatile pin access code. why?, Joerg Desch, 2009/10/27
- Re: [avr-gcc-list] optimizer removes volatile pin access code. why?, Joerg Wunsch, 2009/10/27
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Joerg Desch, 2009/10/28
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, David Brown, 2009/10/28
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Joerg Desch, 2009/10/28
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Erik Christiansen, 2009/10/28
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Joerg Desch, 2009/10/31
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Erik Christiansen, 2009/10/28
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, David Brown, 2009/10/28
- RE: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?,
Stu Bell <=
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, David Brown, 2009/10/29
- RE: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Stu Bell, 2009/10/30
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, df_welch, 2009/10/28
- [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, David Brown, 2009/10/29
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Erik Christiansen, 2009/10/29
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Erik Christiansen, 2009/10/29
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code. why?, Joerg Wunsch, 2009/10/31
- RE: [avr-gcc-list] Re: optimizer removes volatile pin access code.why?, Weddington, Eric, 2009/10/31
- Re: [avr-gcc-list] Re: optimizer removes volatile pin access code.why?, Joerg Wunsch, 2009/10/31
- RE: [avr-gcc-list] Re: optimizer removes volatile pin access code.why?, Weddington, Eric, 2009/10/31