This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -O2 and volatile
- From: "Joseph D. Wagner" <theman at josephdwagner dot info>
- To: Marcus Binny <marcusbinny at yahoo dot com>,gcc at gcc dot gnu dot org
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 2 Oct 2003 03:23:17 +0600
- Subject: Re: -O2 and volatile
- References: <20031002074612.73211.qmail@web60205.mail.yahoo.com>
On Thursday 02 October 2003 01:46 pm, Marcus Binny wrote:
> We sometimes find that our code doesn't work after
> using -O2 GCC optimization. This is usually because
> the compiler decides it can eliminate variables that
> it shouldn't. These variables often reside in ISRs or
> depend on multi-processor interactions.
Try using __volatile__
> Is there a way to find out which variables GCC decided
> to eliminate?
Compile the code with -pg -fprofile-arcs -ftest-coverage
Then use gcov or gprof.
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Gcov.html