Fix llvm::huge_valf multiple initialization (VC)

Yaron Keren yaron.keren at gmail.com
Sat Sep 27 07:51:49 PDT 2014


Thanks, fixed and committed revision 218567.

2014-09-27 17:13 GMT+03:00 Aaron Ballman <aaron at aaronballman.com>:

> On Sat, Sep 27, 2014 at 9:12 AM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
> >  llvm::huge_valf is defined in a header file, so it is initialized
> multiple
> > times in every compiled unit upon program startup.  With non-VC compilers
> > huge_valf  is set to a HUGE_VALF which the compiler can probably optimize
> > out.
> >
> > With VC numeric_limits<float>::infinity() does not return a number but a
> > runtime structure member which therotically may change between calls so
> the
> > compiler does not optimize out the initialization and it happens many
> times.
> > It can be easily seen by placing a breakpoint on the initialization line.
> >
> > This patch moves llvm::huge_valf  initialization to a source file
> instead of
> > the header.
>
> Mostly looks good to me. I would feel more comfortable if
> MathExtras.cpp had a #include <math.h> for the definition of HUGE_VALF
> (I'm sure it's getting pulled in from somewhere, but there's nothing
> explicit in MathExtras.h to pull that header in), but that's a tiny
> nit.
>
> Newlines at the end of file are missing; there's a prop-change, which
> I don't think is something we usually commit (do we?), so those should
> be rectified before committing.
>
> Thanks!
>
> ~Aaron
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140927/057e0e3e/attachment.html>


More information about the llvm-commits mailing list