[sldev] Re: dead code

Soft Noel soft at softnoel.org
Sun Jun 3 23:52:50 PDT 2007


On 5/29/07, Ben Byer <bbyer at mm.st> wrote:
> On May 23, 2007, at 5:11 PM, Dzonatas wrote:
>
> > Andrew Meadows wrote:
> >> Ben Byer -
> >>
> >> Your list undoubtedly contains lots of dead code however I
> >> find some of it suspiciously alive.
> >
> > Compiler optimizations may have moved code from inside one function
> > and stuck it in-line in another. That would give the appearance of
> > dead code. The symbols are generally left inside the object file,
> > but they can be removed if size optimization is desired. I see the
> > default is to compile for speed over size.
>
> Yeah, I think this is what happened.  When I get a chance, I'll try
> rerunning through the same steps with -O0 for both runs -- however,
> I'm not sure if dead code stripping will still happen with
> optimizations turned off.

I don't think the optimization level affects the linker at all, but if
you want to be sure dead stripping still happens no matter what, you
can pass ld the -dead-strip option. A combination of -fno-inline,
-fno-inline-implicit-templates and -fno-inline-functions should make
gcc avoid inlining even with O3... just be sure to specify in the
right order so O3 doesn't stomp on them. :)


More information about the SLDev mailing list