Skip to content

Commit e298b44

Browse files
authored
merge main into amd-staging (llvm#3717)
2 parents a037cca + 8cd4aa6 commit e298b44

File tree

25 files changed

+779
-254
lines changed

25 files changed

+779
-254
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,8 @@
7171
#include <semaphore.h>
7272
#include <signal.h>
7373
#include <stddef.h>
74-
#include <md5.h>
75-
#include <sha224.h>
76-
#include <sha256.h>
77-
#include <sha384.h>
78-
#include <sha512.h>
7974
#include <stdio.h>
8075
#include <stringlist.h>
81-
#include <term.h>
8276
#include <termios.h>
8377
#include <time.h>
8478
#include <ttyent.h>
@@ -370,22 +364,6 @@ const int si_SEGV_MAPERR = SEGV_MAPERR;
370364
const int si_SEGV_ACCERR = SEGV_ACCERR;
371365
const int unvis_valid = UNVIS_VALID;
372366
const int unvis_validpush = UNVIS_VALIDPUSH;
373-
374-
const unsigned MD5_CTX_sz = sizeof(MD5_CTX);
375-
const unsigned MD5_return_length = MD5_DIGEST_STRING_LENGTH;
376-
377-
#define SHA2_CONST(LEN) \
378-
const unsigned SHA##LEN##_CTX_sz = sizeof(SHA##LEN##_CTX); \
379-
const unsigned SHA##LEN##_return_length = SHA##LEN##_DIGEST_STRING_LENGTH; \
380-
const unsigned SHA##LEN##_block_length = SHA##LEN##_BLOCK_LENGTH; \
381-
const unsigned SHA##LEN##_digest_length = SHA##LEN##_DIGEST_LENGTH
382-
383-
SHA2_CONST(224);
384-
SHA2_CONST(256);
385-
SHA2_CONST(384);
386-
SHA2_CONST(512);
387-
388-
#undef SHA2_CONST
389367
} // namespace __sanitizer
390368

391369
using namespace __sanitizer;

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -710,22 +710,6 @@ extern unsigned IOCTL_KDSKBMODE;
710710
extern const int si_SEGV_MAPERR;
711711
extern const int si_SEGV_ACCERR;
712712

713-
extern const unsigned MD5_CTX_sz;
714-
extern const unsigned MD5_return_length;
715-
716-
#define SHA2_EXTERN(LEN) \
717-
extern const unsigned SHA##LEN##_CTX_sz; \
718-
extern const unsigned SHA##LEN##_return_length; \
719-
extern const unsigned SHA##LEN##_block_length; \
720-
extern const unsigned SHA##LEN##_digest_length
721-
722-
SHA2_EXTERN(224);
723-
SHA2_EXTERN(256);
724-
SHA2_EXTERN(384);
725-
SHA2_EXTERN(512);
726-
727-
#undef SHA2_EXTERN
728-
729713
struct __sanitizer_cap_rights {
730714
u64 cr_rights[2];
731715
};

libc/src/__support/FPUtil/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ add_header_library(
231231
Hypot.h
232232
DEPENDS
233233
.basic_operations
234+
.cast
234235
.fenv_impl
235236
.fp_bits
236237
.rounding_mode

libc/src/__support/FPUtil/Hypot.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "BasicOperations.h"
1313
#include "FEnvImpl.h"
1414
#include "FPBits.h"
15+
#include "cast.h"
1516
#include "rounding_mode.h"
1617
#include "src/__support/CPP/bit.h"
1718
#include "src/__support/CPP/type_traits.h"
@@ -133,8 +134,18 @@ LIBC_INLINE T hypot(T x, T y) {
133134
uint16_t a_exp = a_bits.get_biased_exponent();
134135
uint16_t b_exp = b_bits.get_biased_exponent();
135136

136-
if ((a_exp - b_exp >= FPBits_t::FRACTION_LEN + 2) || (x == 0) || (y == 0))
137-
return x_abs.get_val() + y_abs.get_val();
137+
if ((a_exp - b_exp >= FPBits_t::FRACTION_LEN + 2) || (x == 0) || (y == 0)) {
138+
#ifdef LIBC_TYPES_HAS_FLOAT16
139+
if constexpr (cpp::is_same_v<T, float16>) {
140+
// Compiler runtime for basic operations of float16 might not be correctly
141+
// rounded for all rounding modes.
142+
float af = fputil::cast<float>(x_abs.get_val());
143+
float bf = fputil::cast<float>(y_abs.get_val());
144+
return fputil::cast<float16>(af + bf);
145+
} else
146+
#endif // LIBC_TYPES_HAS_FLOAT16
147+
return x_abs.get_val() + y_abs.get_val();
148+
}
138149

139150
uint64_t out_exp = a_exp;
140151
StorageType a_mant = a_bits.get_mantissa();

libc/src/math/generic/hypotf16.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,15 @@ LLVM_LIBC_FUNCTION(float16, hypotf16, (float16 x, float16 y)) {
4848
return a_bits.get_val();
4949
}
5050

51-
// TODO: Investigate why replacing the return line below with:
52-
// return x_bits.get_val() + y_bits.get_val();
53-
// fails the hypotf16 smoke tests.
51+
float af = fputil::cast<float>(a_bits.get_val());
52+
float bf = fputil::cast<float>(b_bits.get_val());
53+
54+
// Compiler runtime basic operations for float16 might not be correctly
55+
// rounded for all rounding modes.
5456
if (LIBC_UNLIKELY(a_u - b_u >=
5557
static_cast<uint16_t>((FPBits::FRACTION_LEN + 2)
5658
<< FPBits::FRACTION_LEN)))
57-
return a_bits.get_val() + b_bits.get_val();
58-
59-
float af = fputil::cast<float>(a_bits.get_val());
60-
float bf = fputil::cast<float>(b_bits.get_val());
59+
return fputil::cast<float16>(af + bf);
6160

6261
// These squares are exact.
6362
float a_sq = af * af;

llvm/include/llvm/ADT/APFloat.h

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,6 @@ class IEEEFloat final {
460460
LLVM_ABI opStatus convertToInteger(MutableArrayRef<integerPart>, unsigned int,
461461
bool, roundingMode, bool *) const;
462462
LLVM_ABI opStatus convertFromAPInt(const APInt &, bool, roundingMode);
463-
LLVM_ABI opStatus convertFromSignExtendedInteger(const integerPart *,
464-
unsigned int, bool,
465-
roundingMode);
466-
LLVM_ABI opStatus convertFromZeroExtendedInteger(const integerPart *,
467-
unsigned int, bool,
468-
roundingMode);
469463
LLVM_ABI Expected<opStatus> convertFromString(StringRef, roundingMode);
470464
LLVM_ABI APInt bitcastToAPInt() const;
471465
LLVM_ABI double convertToDouble() const;
@@ -805,6 +799,16 @@ class DoubleAPFloat final {
805799
unsigned int Width, bool IsSigned,
806800
roundingMode RM, bool *IsExact) const;
807801

802+
// Convert an unsigned integer Src to a floating point number,
803+
// rounding according to RM. The sign of the floating point number is not
804+
// modified.
805+
opStatus convertFromUnsignedParts(const integerPart *Src,
806+
unsigned int SrcCount, roundingMode RM);
807+
808+
// Handle overflow. Sign is preserved. We either become infinity or
809+
// the largest finite number.
810+
opStatus handleOverflow(roundingMode RM);
811+
808812
public:
809813
LLVM_ABI DoubleAPFloat(const fltSemantics &S);
810814
LLVM_ABI DoubleAPFloat(const fltSemantics &S, uninitializedTag);
@@ -860,14 +864,6 @@ class DoubleAPFloat final {
860864
roundingMode RM, bool *IsExact) const;
861865
LLVM_ABI opStatus convertFromAPInt(const APInt &Input, bool IsSigned,
862866
roundingMode RM);
863-
LLVM_ABI opStatus convertFromSignExtendedInteger(const integerPart *Input,
864-
unsigned int InputSize,
865-
bool IsSigned,
866-
roundingMode RM);
867-
LLVM_ABI opStatus convertFromZeroExtendedInteger(const integerPart *Input,
868-
unsigned int InputSize,
869-
bool IsSigned,
870-
roundingMode RM);
871867
LLVM_ABI unsigned int convertToHexString(char *DST, unsigned int HexDigits,
872868
bool UpperCase,
873869
roundingMode RM) const;
@@ -1344,22 +1340,15 @@ class APFloat : public APFloatBase {
13441340
// the precision of the conversion.
13451341
LLVM_ABI opStatus convertToInteger(APSInt &Result, roundingMode RM,
13461342
bool *IsExact) const;
1343+
1344+
// Convert a two's complement integer Input to a floating point number,
1345+
// rounding according to RM. IsSigned is true if the integer is signed,
1346+
// in which case it must be sign-extended.
13471347
opStatus convertFromAPInt(const APInt &Input, bool IsSigned,
13481348
roundingMode RM) {
13491349
APFLOAT_DISPATCH_ON_SEMANTICS(convertFromAPInt(Input, IsSigned, RM));
13501350
}
1351-
opStatus convertFromSignExtendedInteger(const integerPart *Input,
1352-
unsigned int InputSize, bool IsSigned,
1353-
roundingMode RM) {
1354-
APFLOAT_DISPATCH_ON_SEMANTICS(
1355-
convertFromSignExtendedInteger(Input, InputSize, IsSigned, RM));
1356-
}
1357-
opStatus convertFromZeroExtendedInteger(const integerPart *Input,
1358-
unsigned int InputSize, bool IsSigned,
1359-
roundingMode RM) {
1360-
APFLOAT_DISPATCH_ON_SEMANTICS(
1361-
convertFromZeroExtendedInteger(Input, InputSize, IsSigned, RM));
1362-
}
1351+
13631352
LLVM_ABI Expected<opStatus> convertFromString(StringRef, roundingMode);
13641353
APInt bitcastToAPInt() const {
13651354
APFLOAT_DISPATCH_ON_SEMANTICS(bitcastToAPInt());

llvm/include/llvm/ADT/DenseMap.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,12 @@ class DenseMapBase : public DebugEpochBase {
257257
std::pair<iterator, bool> try_emplace(KeyT &&Key, Ts &&...Args) {
258258
BucketT *TheBucket;
259259
if (LookupBucketFor(Key, TheBucket))
260-
return std::make_pair(makeInsertIterator(TheBucket),
261-
false); // Already in map.
260+
return {makeInsertIterator(TheBucket), false}; // Already in map.
262261

263262
// Otherwise, insert the new element.
264263
TheBucket =
265264
InsertIntoBucket(TheBucket, std::move(Key), std::forward<Ts>(Args)...);
266-
return std::make_pair(makeInsertIterator(TheBucket), true);
265+
return {makeInsertIterator(TheBucket), true};
267266
}
268267

269268
// Inserts key,value pair into the map if the key isn't already in the map.
@@ -273,12 +272,11 @@ class DenseMapBase : public DebugEpochBase {
273272
std::pair<iterator, bool> try_emplace(const KeyT &Key, Ts &&...Args) {
274273
BucketT *TheBucket;
275274
if (LookupBucketFor(Key, TheBucket))
276-
return std::make_pair(makeInsertIterator(TheBucket),
277-
false); // Already in map.
275+
return {makeInsertIterator(TheBucket), false}; // Already in map.
278276

279277
// Otherwise, insert the new element.
280278
TheBucket = InsertIntoBucket(TheBucket, Key, std::forward<Ts>(Args)...);
281-
return std::make_pair(makeInsertIterator(TheBucket), true);
279+
return {makeInsertIterator(TheBucket), true};
282280
}
283281

284282
/// Alternate version of insert() which allows a different, and possibly
@@ -291,13 +289,12 @@ class DenseMapBase : public DebugEpochBase {
291289
const LookupKeyT &Val) {
292290
BucketT *TheBucket;
293291
if (LookupBucketFor(Val, TheBucket))
294-
return std::make_pair(makeInsertIterator(TheBucket),
295-
false); // Already in map.
292+
return {makeInsertIterator(TheBucket), false}; // Already in map.
296293

297294
// Otherwise, insert the new element.
298295
TheBucket = InsertIntoBucketWithLookup(TheBucket, std::move(KV.first),
299296
std::move(KV.second), Val);
300-
return std::make_pair(makeInsertIterator(TheBucket), true);
297+
return {makeInsertIterator(TheBucket), true};
301298
}
302299

303300
/// insert - Range insertion of pairs.

llvm/include/llvm/ADT/MapVector.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ class MapVector {
123123
It->second = Vector.size();
124124
Vector.emplace_back(std::piecewise_construct, std::forward_as_tuple(Key),
125125
std::forward_as_tuple(std::forward<Ts>(Args)...));
126-
return std::make_pair(std::prev(end()), true);
126+
return {std::prev(end()), true};
127127
}
128-
return std::make_pair(begin() + It->second, false);
128+
return {begin() + It->second, false};
129129
}
130130
template <typename... Ts>
131131
std::pair<iterator, bool> try_emplace(KeyT &&Key, Ts &&...Args) {
@@ -135,9 +135,9 @@ class MapVector {
135135
Vector.emplace_back(std::piecewise_construct,
136136
std::forward_as_tuple(std::move(Key)),
137137
std::forward_as_tuple(std::forward<Ts>(Args)...));
138-
return std::make_pair(std::prev(end()), true);
138+
return {std::prev(end()), true};
139139
}
140-
return std::make_pair(begin() + It->second, false);
140+
return {begin() + It->second, false};
141141
}
142142

143143
std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &KV) {

llvm/include/llvm/ADT/SmallPtrSet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ class SmallPtrSetImplBase : public DebugEpochBase {
172172
// Check to see if it is already in the set.
173173
for (const void *&Bucket : small_buckets()) {
174174
if (Bucket == Ptr)
175-
return std::make_pair(&Bucket, false);
175+
return {&Bucket, false};
176176
}
177177

178178
// Nope, there isn't. If we stay small, just 'pushback' now.
179179
if (NumEntries < CurArraySize) {
180180
CurArray[NumEntries++] = Ptr;
181181
incrementEpoch();
182-
return std::make_pair(CurArray + (NumEntries - 1), true);
182+
return {CurArray + (NumEntries - 1), true};
183183
}
184184
// Otherwise, hit the big set case, which will call grow.
185185
}
@@ -400,7 +400,7 @@ class SmallPtrSetImpl : public SmallPtrSetImplBase {
400400
/// the element equal to Ptr.
401401
std::pair<iterator, bool> insert(PtrType Ptr) {
402402
auto p = insert_imp(PtrTraits::getAsVoidPointer(Ptr));
403-
return std::make_pair(makeIterator(p.first), p.second);
403+
return {makeIterator(p.first), p.second};
404404
}
405405

406406
/// Insert the given pointer with an iterator hint that is ignored. This is

llvm/include/llvm/ADT/SparseSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ class SparseSet {
258258
unsigned Idx = ValIndexOf(Val);
259259
iterator I = findIndex(Idx);
260260
if (I != end())
261-
return std::make_pair(I, false);
261+
return {I, false};
262262
Sparse[Idx] = size();
263263
Dense.push_back(Val);
264-
return std::make_pair(end() - 1, true);
264+
return {end() - 1, true};
265265
}
266266

267267
/// array subscript - If an element already exists with this key, return it.

0 commit comments

Comments
 (0)