Fix llvm::huge_valf multiple initialization (VC)
Aaron Ballman
aaron at aaronballman.com
Sat Sep 27 07:13:43 PDT 2014
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
More information about the llvm-commits
mailing list