mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-03 17:31:50 +00:00
af34c3a995
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
33 lines
885 B
C++
33 lines
885 B
C++
//===-- MathExtras.cpp - Implement the MathExtras header --------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the MathExtras.h header
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Support/MathExtras.h"
|
|
|
|
#ifdef _MSC_VER
|
|
#include <limits>
|
|
#else
|
|
#include <math.h>
|
|
#endif
|
|
|
|
namespace llvm {
|
|
|
|
#if defined(_MSC_VER)
|
|
// Visual Studio defines the HUGE_VAL class of macros using purposeful
|
|
// constant arithmetic overflow, which it then warns on when encountered.
|
|
const float huge_valf = std::numeric_limits<float>::infinity();
|
|
#else
|
|
const float huge_valf = HUGE_VALF;
|
|
#endif
|
|
|
|
}
|