Skip to content

Commit b5d7b05

Browse files
committed
Make LLVM libc a required dependency and address comments.
1 parent 98fb0d0 commit b5d7b05

File tree

6 files changed

+8
-30
lines changed

6 files changed

+8
-30
lines changed

llvm/CMakeLists.txt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -659,15 +659,9 @@ endif()
659659

660660
set(LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}")
661661

662-
set(LLVM_INTEGRATE_LIBC "OFF" CACHE STRING "Use LLVM libc code directly if available.")
663-
664-
if(LLVM_INTEGRATE_LIBC)
665-
message(STATUS "LLVM_INTEGRATE_LIBC is ${LLVM_INTEGRATE_LIBC}")
666-
include(FindLibcCommonUtils)
667-
if(NOT TARGET llvm-libc-common-utilities)
668-
message(STATUS "LLVM_INTEGRATE_LIBC is set but cannot find LLVM libc at ${libc_path}.")
669-
set(LLVM_INTEGRATE_LIBC OFF)
670-
endif()
662+
include(FindLibcCommonUtils)
663+
if(NOT TARGET llvm-libc-common-utilities)
664+
message(FATAL_ERROR "LLVM libc is not found at ${libc_path}.")
671665
endif()
672666

673667

llvm/include/llvm/ADT/APFloat.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,9 +1526,7 @@ class APFloat : public APFloatBase {
15261526
friend IEEEFloat;
15271527
friend DoubleAPFloat;
15281528

1529-
#ifdef LLVM_INTEGRATE_LIBC
15301529
friend APFloat exp(const APFloat &X, roundingMode RM);
1531-
#endif // LLVM_INTEGRATE_LIBC
15321530
};
15331531

15341532
static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
@@ -1662,11 +1660,9 @@ inline APFloat maximumnum(const APFloat &A, const APFloat &B) {
16621660
return A < B ? B : A;
16631661
}
16641662

1665-
#ifdef LLVM_INTEGRATE_LIBC
16661663
/// Implement IEEE 754-2019 exp functions.
16671664
LLVM_READONLY
16681665
APFloat exp(const APFloat &X, RoundingMode RM = APFloat::rmNearestTiesToEven);
1669-
#endif // LLVM_INTEGRATE_LIBC
16701666

16711667
inline raw_ostream &operator<<(raw_ostream &OS, const APFloat &V) {
16721668
V.print(OS);

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,4 @@
143143
coverage bugs, and to 0 otherwise. */
144144
#cmakedefine01 LLVM_ENABLE_DEBUGLOC_TRACKING_ORIGIN
145145

146-
/* Define if LLVM and clang uses LLVM libc for math computations. */
147-
#cmakedefine LLVM_INTEGRATE_LIBC
148-
149146
#endif

llvm/lib/Support/APFloat.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828
#include <cstring>
2929
#include <limits.h>
3030

31-
#ifdef LLVM_INTEGRATE_LIBC
3231
// Shared headers from LLVM libc
3332
#include "shared/math.h"
34-
#endif // LLVM_INTEGRATE_LIBC
3533

3634
#define APFLOAT_DISPATCH_ON_SEMANTICS(METHOD_CALL) \
3735
do { \
@@ -5606,7 +5604,6 @@ float APFloat::convertToFloat() const {
56065604
return Temp.getIEEE().convertToFloat();
56075605
}
56085606

5609-
#ifdef LLVM_INTEGRATE_LIBC
56105607
static constexpr int getFEnvRoundingMode(llvm::RoundingMode rm) {
56115608
switch (rm) {
56125609
case APFloat::rmTowardPositive:
@@ -5622,16 +5619,13 @@ static constexpr int getFEnvRoundingMode(llvm::RoundingMode rm) {
56225619
}
56235620

56245621
APFloat exp(const APFloat &X, RoundingMode rounding_mode) {
5625-
assert((&X.getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle) &&
5626-
"Float semantics is not IEEEsingle");
56275622
if (&X.getSemantics() == (const llvm::fltSemantics *)&semIEEEsingle) {
56285623
float result = LIBC_NAMESPACE::shared::expf(
56295624
X.convertToFloat(), getFEnvRoundingMode(rounding_mode));
56305625
return APFloat(result);
56315626
}
5632-
llvm_unreachable("Unexpected semantics");
5627+
assert(false && "Unsupported floating-point semantics");
56335628
}
5634-
#endif // LLVM_INTEGRATE_LIBC
56355629

56365630
} // namespace llvm
56375631

llvm/lib/Support/CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ target_include_directories(LLVMSupport SYSTEM
385385
${LLVM_THIRD_PARTY_DIR}/siphash/include
386386
)
387387

388-
if(LLVM_INTEGRATE_LIBC)
389-
set_property(TARGET LLVMSupport PROPERTY CXX_STANDARD 17)
390-
target_include_directories(LLVMSupport PRIVATE "${LLVM_INCLUDE_DIR}/../../libc")
391-
target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.
392-
endif()
388+
# Integrating LLVM libc's math functions
389+
set_property(TARGET LLVMSupport PROPERTY CXX_STANDARD 17)
390+
target_include_directories(LLVMSupport PRIVATE "${LLVM_INCLUDE_DIR}/../../libc")
391+
target_compile_options(LLVMSupport PRIVATE "-Wno-c99-extensions") # _Complex warnings.

llvm/unittests/ADT/APFloatTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8357,7 +8357,6 @@ TEST(APFloatTest, hasSignBitInMSB) {
83578357
EXPECT_FALSE(APFloat::hasSignBitInMSB(APFloat::Float8E8M0FNU()));
83588358
}
83598359

8360-
#ifdef LLVM_INTEGRATE_LIBC
83618360
TEST(APFloatTest, expf) {
83628361
std::array<llvm::RoundingMode, 4> allRoundingModes = {
83638362
APFloat::rmNearestTiesToEven, APFloat::rmTowardPositive,
@@ -8431,6 +8430,5 @@ TEST(APFloatTest, expf) {
84318430
EXPECT_EQ(0x1.78b562p-2f,
84328431
llvm::exp(APFloat(-1.0f), APFloat::rmTowardZero).convertToFloat());
84338432
}
8434-
#endif // LLVM_INTEGRATE_LIBC
84358433

84368434
} // namespace

0 commit comments

Comments
 (0)