bad dead code detection ?

tm_gccmail@mail.kloo.net tm_gccmail@mail.kloo.net
Wed Jun 25 21:41:00 GMT 2003


On Wed, 25 Jun 2003, Daniel Jacobowitz wrote:

> 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.

I've run into this problem in other situations. IMHO, we need to find a
way to support this (inline assembly which changes the control
flow) either by disabling most optimizations on a per-function basis.

Toshi






More information about the Gcc mailing list