This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bad dead code detection ?


On Wed, Jun 25, 2003 at 03:52:55PM +0200, David Jobet wrote:
> Hello,
> 
> I try to write an exception handling library, and I'm forced to play with gcc
> inline assembly.
> You will find below a sample program.
> 
> The trick is to register address of local labels in a global static table. Later
> when an exception is launched, I manage to jump to this label to do clean up.
> The problem is gcc detects the label cannot be reached and dead code elimination
> completely remove the exception handling code from the executable when compiled
> with -O3.
> When compiled without -03, the code is not removed, but the label is moved from
> the *good* location to the return label.
> 
> I'm wondering if it's a bug, or if there is a way to prevent this.
> When one take the address of a local variable, it cannot be put in a register.
> I'm wondering if it should not be the same with code taking address of local
> labels ?

You simply can't do this:  inline assembly must not change the control
flow of the program.  Period.  The compiler can not be expected to cope
with it.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]