Fix llvm::huge_valf multiple initializations with Visual C++.
authorYaron Keren <yaron.keren@gmail.com>
Sat, 27 Sep 2014 14:41:29 +0000 (14:41 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Sat, 27 Sep 2014 14:41:29 +0000 (14:41 +0000)
commitaf34c3a9952b274d4adcc2cc46aca6ee03f7b24b
treee8b32dd14c9dd27d1d85e69201b1dfb3858549b9
parentb66b0cf2ebe25eafbfad7b54ebc96a9b260fb57d
Fix llvm::huge_valf multiple initializations with Visual C++.

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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218567 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/MathExtras.h
lib/Support/CMakeLists.txt
lib/Support/MathExtras.cpp [new file with mode: 0644]