Skip to content

Commit 10a675e

Browse files
committed
Merge branch 'main' into vplan-runtime-checks
2 parents be2c3a6 + 466b393 commit 10a675e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+244
-151
lines changed

libc/src/math/generic/log1p.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,8 @@ constexpr Float128 BIG_COEFFS[4]{
822822
{Sign::NEG, -128, 0x80000000'00000000'00000000'00000000_u128},
823823
};
824824

825-
LIBC_INLINE double log1p_accurate(int e_x, int index,
826-
fputil::DoubleDouble m_x) {
825+
[[maybe_unused]] LIBC_INLINE double log1p_accurate(int e_x, int index,
826+
fputil::DoubleDouble m_x) {
827827
Float128 e_x_f128(static_cast<float>(e_x));
828828
Float128 sum = fputil::quick_mul(LOG_2, e_x_f128);
829829
sum = fputil::quick_add(sum, LOG_R1[index]);
@@ -882,7 +882,6 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
882882

883883
constexpr int EXP_BIAS = FPBits_t::EXP_BIAS;
884884
constexpr int FRACTION_LEN = FPBits_t::FRACTION_LEN;
885-
constexpr uint64_t FRACTION_MASK = FPBits_t::FRACTION_MASK;
886885
FPBits_t xbits(x);
887886
uint64_t x_u = xbits.uintval();
888887

@@ -954,12 +953,12 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
954953
// |x_dd.lo| < ulp(x_dd.hi)
955954

956955
FPBits_t xhi_bits(x_dd.hi);
956+
uint64_t xhi_frac = xhi_bits.get_mantissa();
957957
x_u = xhi_bits.uintval();
958958
// Range reduction:
959959
// Find k such that |x_hi - k * 2^-7| <= 2^-8.
960-
int idx =
961-
static_cast<int>(((x_u & FRACTION_MASK) + (1ULL << (FRACTION_LEN - 8))) >>
962-
(FRACTION_LEN - 7));
960+
int idx = static_cast<int>((xhi_frac + (1ULL << (FRACTION_LEN - 8))) >>
961+
(FRACTION_LEN - 7));
963962
int x_e = xhi_bits.get_exponent() + (idx >> 7);
964963
double e_x = static_cast<double>(x_e);
965964

@@ -974,17 +973,21 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
974973
constexpr double ERR_HI[2] = {0x1.0p-85, 0.0};
975974
double err_hi = ERR_HI[hi == 0.0];
976975

977-
// Scaling factior = 2^(-xh_bits.get_exponent())
978-
uint64_t s_u = (static_cast<uint64_t>(EXP_BIAS) << (FRACTION_LEN + 1)) -
979-
(x_u & FPBits_t::EXP_MASK);
980-
// When the exponent of x is 2^1023, its inverse, 2^(-1023), is subnormal.
981-
const double EXPONENT_CORRECTION[2] = {0.0, 0x1.0p-1023};
982-
double scaling = FPBits_t(s_u).get_val() + EXPONENT_CORRECTION[s_u == 0];
976+
// Scale x_dd by 2^(-xh_bits.get_exponent()).
977+
int64_t s_u = static_cast<int64_t>(x_u & FPBits_t::EXP_MASK) -
978+
(static_cast<int64_t>(EXP_BIAS) << FRACTION_LEN);
983979
// Normalize arguments:
984980
// 1 <= m_dd.hi < 2
985981
// |m_dd.lo| < 2^-52.
986982
// This is exact.
987-
fputil::DoubleDouble m_dd{scaling * x_dd.lo, scaling * x_dd.hi};
983+
uint64_t m_hi = FPBits_t::one().uintval() | xhi_frac;
984+
985+
uint64_t m_lo =
986+
FPBits_t(x_dd.lo).abs().get_val() > x_dd.hi * 0x1.0p-127
987+
? static_cast<uint64_t>(cpp::bit_cast<int64_t>(x_dd.lo) - s_u)
988+
: 0;
989+
990+
fputil::DoubleDouble m_dd{FPBits_t(m_lo).get_val(), FPBits_t(m_hi).get_val()};
988991

989992
// Perform range reduction:
990993
// r * m - 1 = r * (m_dd.hi + m_dd.lo) - 1

libc/test/src/math/smoke/log1p_test.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "test/UnitTest/FPMatcher.h"
1414
#include "test/UnitTest/Test.h"
1515

16-
#include <stdint.h>
17-
1816
using LlvmLibcLog1pTest = LIBC_NAMESPACE::testing::FPTest<double>;
1917

2018
TEST_F(LlvmLibcLog1pTest, SpecialNumbers) {
@@ -26,6 +24,9 @@ TEST_F(LlvmLibcLog1pTest, SpecialNumbers) {
2624
EXPECT_FP_EQ(neg_zero, LIBC_NAMESPACE::log1p(-0.0));
2725
EXPECT_FP_EQ_WITH_EXCEPTION(neg_inf, LIBC_NAMESPACE::log1p(-1.0),
2826
FE_DIVBYZERO);
27+
28+
EXPECT_FP_EQ(0x1.62c829bf8fd9dp9,
29+
LIBC_NAMESPACE::log1p(0x1.9b536cac3a09dp1023));
2930
}
3031

3132
#ifdef LIBC_TEST_FTZ_DAZ
@@ -36,18 +37,24 @@ TEST_F(LlvmLibcLog1pTest, FTZMode) {
3637
ModifyMXCSR mxcsr(FTZ);
3738

3839
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::log1p(min_denormal));
40+
EXPECT_FP_EQ(0x1.62c829bf8fd9dp9,
41+
LIBC_NAMESPACE::log1p(0x1.9b536cac3a09dp1023));
3942
}
4043

4144
TEST_F(LlvmLibcLog1pTest, DAZMode) {
4245
ModifyMXCSR mxcsr(DAZ);
4346

4447
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::log1p(min_denormal));
48+
EXPECT_FP_EQ(0x1.62c829bf8fd9dp9,
49+
LIBC_NAMESPACE::log1p(0x1.9b536cac3a09dp1023));
4550
}
4651

4752
TEST_F(LlvmLibcLog1pTest, FTZDAZMode) {
4853
ModifyMXCSR mxcsr(FTZ | DAZ);
4954

5055
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::log1p(min_denormal));
56+
EXPECT_FP_EQ(0x1.62c829bf8fd9dp9,
57+
LIBC_NAMESPACE::log1p(0x1.9b536cac3a09dp1023));
5158
}
5259

5360
#endif

lldb/tools/lldb-dap/DAP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ bool DAP::HandleObject(const llvm::json::Object &object) {
692692
const auto packet_type = GetString(object, "type");
693693
if (packet_type == "request") {
694694
const auto command = GetString(object, "command");
695-
auto handler_pos = request_handlers.find(std::string(command));
695+
auto handler_pos = request_handlers.find(command);
696696
if (handler_pos != request_handlers.end()) {
697697
handler_pos->second(object);
698698
return true; // Success

lldb/tools/lldb-dap/DAP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct DAP {
171171
// the old process here so we can detect this case and keep running.
172172
lldb::pid_t restarting_process_id;
173173
bool configuration_done_sent;
174-
std::map<std::string, RequestCallback> request_handlers;
174+
std::map<std::string, RequestCallback, std::less<>> request_handlers;
175175
bool waiting_for_run_in_terminal;
176176
ProgressEventReporter progress_event_reporter;
177177
// Keep track of the last stop thread index IDs as threads won't go away

llvm/include/llvm/DebugInfo/GSYM/OutputAggregator.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ class OutputAggregator {
6060
// then merge it in here. Note that this is *not* thread safe. It is up to
6161
// the caller to ensure that this is only called from one thread at a time.
6262
void Merge(const OutputAggregator &other) {
63-
for (auto &&[name, count] : other.Aggregation) {
64-
auto [it, inserted] = Aggregation.emplace(name, count);
65-
if (!inserted)
66-
it->second += count;
67-
}
63+
for (auto &&[name, count] : other.Aggregation)
64+
Aggregation[name] += count;
6865
}
6966
};
7067

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,15 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
20792079
LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, true)
20802080

20812081
#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type) \
2082+
namespace llvm { \
2083+
namespace yaml { \
2084+
template <> struct LLVM_ABI MappingTraits<Type> { \
2085+
static void mapping(IO &IO, Type &Obj); \
2086+
}; \
2087+
} \
2088+
}
2089+
2090+
#define LLVM_YAML_DECLARE_MAPPING_TRAITS_PRIVATE(Type) \
20822091
namespace llvm { \
20832092
namespace yaml { \
20842093
template <> struct MappingTraits<Type> { \
@@ -2090,7 +2099,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
20902099
#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type) \
20912100
namespace llvm { \
20922101
namespace yaml { \
2093-
template <> struct ScalarEnumerationTraits<Type> { \
2102+
template <> struct LLVM_ABI ScalarEnumerationTraits<Type> { \
20942103
static void enumeration(IO &io, Type &Value); \
20952104
}; \
20962105
} \
@@ -2099,7 +2108,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
20992108
#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type) \
21002109
namespace llvm { \
21012110
namespace yaml { \
2102-
template <> struct ScalarBitSetTraits<Type> { \
2111+
template <> struct LLVM_ABI ScalarBitSetTraits<Type> { \
21032112
static void bitset(IO &IO, Type &Options); \
21042113
}; \
21052114
} \
@@ -2108,7 +2117,7 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
21082117
#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote) \
21092118
namespace llvm { \
21102119
namespace yaml { \
2111-
template <> struct ScalarTraits<Type> { \
2120+
template <> struct LLVM_ABI ScalarTraits<Type> { \
21122121
static void output(const Type &Value, void *ctx, raw_ostream &Out); \
21132122
static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
21142123
static QuotingType mustQuote(StringRef) { return MustQuote; } \

llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "MCTargetDesc/X86MCTargetDesc.h"
1414
#include "MCTargetDesc/X86TargetStreamer.h"
1515
#include "TargetInfo/X86TargetInfo.h"
16-
#include "X86AsmParserCommon.h"
1716
#include "X86Operand.h"
1817
#include "llvm/ADT/STLExtras.h"
1918
#include "llvm/ADT/SmallString.h"

llvm/lib/Target/X86/GISel/X86CallLowering.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include "llvm/IR/DataLayout.h"
4444
#include "llvm/IR/Function.h"
4545
#include "llvm/IR/Value.h"
46-
#include "llvm/MC/MCRegisterInfo.h"
4746
#include <cassert>
4847
#include <cstdint>
4948

llvm/lib/Target/X86/GISel/X86InstructionSelector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "llvm/IR/DataLayout.h"
3939
#include "llvm/IR/InstrTypes.h"
4040
#include "llvm/IR/IntrinsicsX86.h"
41-
#include "llvm/Support/AtomicOrdering.h"
4241
#include "llvm/Support/CodeGen.h"
4342
#include "llvm/Support/Debug.h"
4443
#include "llvm/Support/ErrorHandling.h"

llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/MC/MCInstrAnalysis.h"
2020
#include "llvm/MC/MCInstrInfo.h"
2121
#include "llvm/MC/MCSubtargetInfo.h"
22-
#include "llvm/Support/Casting.h"
2322
#include "llvm/Support/ErrorHandling.h"
2423
#include "llvm/Support/Format.h"
2524
#include "llvm/Support/raw_ostream.h"

0 commit comments

Comments
 (0)