[llvm-commits] CVS: llvm/include/llvm/Support/Debug.h

Reid Spencer rspencer at reidspencer.com
Thu Nov 16 18:25:00 PST 2006


Hi Bill,

On Thu, 2006-11-16 at 17:44 -0800, Bill Wendling wrote:
> On 11/16/06, Reid Spencer <rspencer at reidspencer.com> wrote:
> > While this may not print anything when NDEBUG is *not* defined, it isn't
> > sufficient. You're going to leave template functions scattered all over
> > the place and calls to them. The existing solution completely eliminates
> > the code from an NDEBUG build. That's what we want. What's wrong with
> > the existing solution?  Or, perhaps a combination is needed. Something
> > like:
> >
> > DEBUG(DOUT << "This is a debug message\n");
> >
> Hi Reid,
> 
> Basically, this is to get rid of static c'tor/d'tors scattered all
> over the source tree. (You get them whenever you #include <iostream>.)
> A smart compiler should be able to remove all of the empty functions
> because they don't have any side-effects.

I understand the motivation for the change and I commend it, but I'm
concerned about getting it right. You're assuming a few things: a) the
compiler is smart enough to get rid of calls that have no side effects,
b) the compiler knows how to determine if a function has no side effects
without help (operator<< isn't marked "pure"), and c) that there aren't
any side effects.  c) can probably be proven by your iostream
implementation but a) and b) are a little tougher. 

Can we build an optimized, with symbols (-g -O2) version of one of these
modules and see if those symbols are getting removed ?  If so, I'm fine
with it. If not, we need a new strategy.

Reid.





More information about the llvm-commits mailing list