Skip to content

Commit 1ef01ee

Browse files
committed
merge main into amd-staging
Change-Id: Ief047b8931f227872f3af719811c6baaea45d94e
2 parents 1c98c4b + cde4ae7 commit 1ef01ee

File tree

26 files changed

+170
-184
lines changed

26 files changed

+170
-184
lines changed

compiler-rt/test/profile/ContinuousSyncMode/online-merging.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
// Create two DSOs and a driver program that uses them.
99
// RUN: echo "void dso1(void) {}" > dso1.c
1010
// RUN: echo "void dso2(void) {}" > dso2.c
11-
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso1.dylib dso1.c -mllvm -instrprof-atomic-counter-update-all=1
12-
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso2.dylib dso2.c -mllvm -instrprof-atomic-counter-update-all=1
13-
// RUN: %clang_pgogen_cont -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -mllvm -instrprof-atomic-counter-update-all=1
11+
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso1.dylib dso1.c -fprofile-update=atomic
12+
// RUN: %clang_pgogen_cont %shared_lib_flag -o %t.dir/dso2.dylib dso2.c -fprofile-update=atomic
13+
// RUN: %clang_pgogen_cont -o main.exe %s %t.dir/dso1.dylib %t.dir/dso2.dylib -fprofile-update=atomic
1414
//
1515
// === Round 1 ===
1616
// Test merging+continuous mode without any file contention.

libc/fuzzing/__support/hashtable_fuzz.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
///
1111
//===----------------------------------------------------------------------===//
1212
#include "include/llvm-libc-types/ENTRY.h"
13+
#include "src/__support/CPP/bit.h"
1314
#include "src/__support/CPP/string_view.h"
1415
#include "src/__support/HashTable/table.h"
1516
#include "src/__support/macros/config.h"
@@ -81,15 +82,14 @@ static struct {
8182

8283
template <typename T> T next() {
8384
static_assert(cpp::is_integral<T>::value, "T must be an integral type");
84-
union {
85-
T result;
86-
char data[sizeof(T)];
87-
};
88-
for (size_t i = 0; i < sizeof(result); i++)
85+
86+
char data[sizeof(T)];
87+
88+
for (size_t i = 0; i < sizeof(T); i++)
8989
data[i] = buffer[i];
90-
buffer += sizeof(result);
91-
remaining -= sizeof(result);
92-
return result;
90+
buffer += sizeof(T);
91+
remaining -= sizeof(T);
92+
return cpp::bit_cast<T>(data);
9393
}
9494

9595
cpp::string_view next_string() {

libc/src/__support/HashTable/generic/bitmask_impl.inc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "src/__support/CPP/bit.h"
910
#include "src/__support/common.h"
1011
#include "src/__support/endian_internal.h"
1112
#include "src/__support/macros/config.h"
@@ -44,13 +45,11 @@ struct Group {
4445

4546
// Load a group of control words from an arbitary address.
4647
LIBC_INLINE static Group load(const void *addr) {
47-
union {
48-
bitmask_t value;
49-
char bytes[sizeof(bitmask_t)];
50-
} data;
48+
char bytes[sizeof(bitmask_t)];
49+
5150
for (size_t i = 0; i < sizeof(bitmask_t); ++i)
52-
data.bytes[i] = static_cast<const char *>(addr)[i];
53-
return {data.value};
51+
bytes[i] = static_cast<const char *>(addr)[i];
52+
return Group{cpp::bit_cast<bitmask_t>(bytes)};
5453
}
5554

5655
// Load a group of control words from an aligned address.

libc/src/__support/hash.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "src/__support/CPP/limits.h" // numeric_limits
1414
#include "src/__support/macros/attributes.h" // LIBC_INLINE
1515
#include "src/__support/macros/config.h"
16-
#include "src/__support/uint128.h" // UInt128
17-
#include <stdint.h> // For uint64_t
16+
#include "src/__support/uint128.h" // UInt128
17+
#include <stdint.h> // For uint64_t
1818

1919
namespace LIBC_NAMESPACE_DECL {
2020
namespace internal {
@@ -34,25 +34,23 @@ LIBC_INLINE uint64_t folded_multiply(uint64_t x, uint64_t y) {
3434
// Therefore, we use a union to read the value.
3535
template <typename T> LIBC_INLINE T read_little_endian(const void *ptr) {
3636
const uint8_t *bytes = static_cast<const uint8_t *>(ptr);
37-
union {
38-
T value;
39-
uint8_t buffer[sizeof(T)];
40-
} data;
37+
uint8_t buffer[sizeof(T)];
4138
#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
42-
// Compiler should able to optimize this as a load followed by a byte swap.
43-
// On aarch64 (-mbig-endian), this compiles to the following for int:
39+
// Compiler should able to optimize this as a load followed by a byte
40+
// swap. On aarch64 (-mbig-endian), this compiles to the following for
41+
// int:
4442
// ldr w0, [x0]
4543
// rev w0, w0
4644
// ret
4745
for (size_t i = 0; i < sizeof(T); ++i) {
48-
data.buffer[i] = bytes[sizeof(T) - i - 1];
46+
buffer[i] = bytes[sizeof(T) - i - 1];
4947
}
5048
#else
5149
for (size_t i = 0; i < sizeof(T); ++i) {
52-
data.buffer[i] = bytes[i];
50+
buffer[i] = bytes[i];
5351
}
5452
#endif
55-
return data.value;
53+
return cpp::bit_cast<T>(buffer);
5654
}
5755

5856
// Specialized read functions for small values. size must be <= 8.

libc/src/math/generic/exp10m1f16.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ LLVM_LIBC_FUNCTION(float16, exp10m1f16, (float16 x)) {
119119

120120
// When |x| <= 2^(-3).
121121
if (x_abs <= 0x3000U) {
122+
if (LIBC_UNLIKELY(x_abs == 0))
123+
return x;
124+
122125
if (auto r = EXP10M1F16_EXCEPTS_LO.lookup(x_u);
123126
LIBC_UNLIKELY(r.has_value()))
124127
return r.value();

libc/src/math/generic/tanhf16.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ LLVM_LIBC_FUNCTION(float16, tanhf16, (float16 x)) {
6464

6565
// When |x| <= 0x1.d2p-4.
6666
if (x_abs <= 0x2f48U) {
67+
if (LIBC_UNLIKELY(x_abs == 0))
68+
return x;
69+
6770
float xf = x;
6871
float xf_sq = xf * xf;
6972
// Degree-7 Taylor expansion generated by Sollya with the following

libc/test/src/__support/HashTable/group_test.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "src/__support/HashTable/bitmask.h"
1010

11+
#include "src/__support/CPP/bit.h"
1112
#include "src/__support/macros/config.h"
1213
#include "src/stdlib/rand.h"
1314
#include "test/UnitTest/Test.h"
@@ -28,14 +29,13 @@ TEST(LlvmLibcHashTableBitMaskTest, Match) {
2829
size_t appearance[4][sizeof(Group)];
2930
ByteArray array{};
3031

31-
union {
32-
uintptr_t random;
33-
int data[sizeof(uintptr_t) / sizeof(int)];
34-
};
32+
int data[sizeof(uintptr_t) / sizeof(int)];
3533

3634
for (int &i : data)
3735
i = rand();
3836

37+
uintptr_t random = cpp::bit_cast<uintptr_t>(data);
38+
3939
for (size_t i = 0; i < sizeof(Group); ++i) {
4040
size_t choice = random % 4;
4141
random /= 4;
@@ -62,14 +62,13 @@ TEST(LlvmLibcHashTableBitMaskTest, MaskAvailable) {
6262
for (size_t i = 0; i < sizeof(Group); ++i) {
6363
ByteArray array{};
6464

65-
union {
66-
uintptr_t random;
67-
int data[sizeof(uintptr_t) / sizeof(int)];
68-
};
65+
int data[sizeof(uintptr_t) / sizeof(int)];
6966

7067
for (int &j : data)
7168
j = rand();
7269

70+
uintptr_t random = cpp::bit_cast<uintptr_t>(data);
71+
7372
ASSERT_FALSE(Group::load(array.data).mask_available().any_bit_set());
7473

7574
array.data[i] = 0x80;

libc/test/src/__support/HashTable/table_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ TEST(LlvmLibcTableTest, GrowthSequence) {
8282
}
8383

8484
TEST(LlvmLibcTableTest, Insertion) {
85-
union key {
85+
struct key {
8686
char bytes[2];
8787
} keys[256];
8888
for (size_t k = 0; k < 256; ++k) {

lldb/test/Shell/Unwind/windows-unaligned-x86_64.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ breakpoint set -n func
1717
# CHECK: Breakpoint 1: where = {{.*}}`{{(::)?}}func
1818

1919
process launch
20-
# CHECK: stop reason = breakpoint 1.1
20+
# CHECK: stop reason = breakpoint 1
2121

2222
thread backtrace
2323
# CHECK: frame #0: {{.*}}`{{(::)?}}func

llvm/lib/Linker/IRMover.cpp

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ class TypeMapTy : public ValueMapTypeRemapper {
8282
Type *get(Type *SrcTy);
8383
Type *get(Type *SrcTy, SmallPtrSet<StructType *, 8> &Visited);
8484

85-
void finishType(StructType *DTy, StructType *STy, ArrayRef<Type *> ETypes);
86-
8785
FunctionType *get(FunctionType *T) {
8886
return cast<FunctionType>(get((Type *)T));
8987
}
@@ -233,20 +231,6 @@ Error TypeMapTy::linkDefinedTypeBodies() {
233231
return Error::success();
234232
}
235233

236-
void TypeMapTy::finishType(StructType *DTy, StructType *STy,
237-
ArrayRef<Type *> ETypes) {
238-
DTy->setBody(ETypes, STy->isPacked());
239-
240-
// Steal STy's name.
241-
if (STy->hasName()) {
242-
SmallString<16> TmpName = STy->getName();
243-
STy->setName("");
244-
DTy->setName(TmpName);
245-
}
246-
247-
DstStructTypesSet.addNonOpaque(DTy);
248-
}
249-
250234
Type *TypeMapTy::get(Type *Ty) {
251235
SmallPtrSet<StructType *, 8> Visited;
252236
return get(Ty, Visited);
@@ -292,17 +276,9 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
292276
AnyChange |= ElementTypes[I] != Ty->getContainedType(I);
293277
}
294278

295-
// If we found our type while recursively processing stuff, just use it.
279+
// Refresh Entry after recursively processing stuff.
296280
Entry = &MappedTypes[Ty];
297-
if (*Entry) {
298-
if (auto *DTy = dyn_cast<StructType>(*Entry)) {
299-
if (DTy->isOpaque()) {
300-
auto *STy = cast<StructType>(Ty);
301-
finishType(DTy, STy, ElementTypes);
302-
}
303-
}
304-
return *Entry;
305-
}
281+
assert(!*Entry && "Recursive type!");
306282

307283
// If all of the element types mapped directly over and the type is not
308284
// a named struct, then the type is usable as-is.
@@ -350,8 +326,17 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
350326
return *Entry = Ty;
351327
}
352328

353-
StructType *DTy = StructType::create(Ty->getContext());
354-
finishType(DTy, STy, ElementTypes);
329+
StructType *DTy =
330+
StructType::create(Ty->getContext(), ElementTypes, "", STy->isPacked());
331+
332+
// Steal STy's name.
333+
if (STy->hasName()) {
334+
SmallString<16> TmpName = STy->getName();
335+
STy->setName("");
336+
DTy->setName(TmpName);
337+
}
338+
339+
DstStructTypesSet.addNonOpaque(DTy);
355340
return *Entry = DTy;
356341
}
357342
}

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,7 @@ bool AArch64DAGToDAGISel::SelectRDVLImm(SDValue N, SDValue &Imm) {
920920
if ((MulImm % std::abs(Scale)) == 0) {
921921
int64_t RDVLImm = MulImm / Scale;
922922
if ((RDVLImm >= Low) && (RDVLImm <= High)) {
923-
Imm = CurDAG->getSignedConstant(RDVLImm, SDLoc(N), MVT::i32,
924-
/*isTarget=*/true);
923+
Imm = CurDAG->getSignedTargetConstant(RDVLImm, SDLoc(N), MVT::i32);
925924
return true;
926925
}
927926
}
@@ -4283,7 +4282,7 @@ bool AArch64DAGToDAGISel::SelectSVESignedArithImm(SDValue N, SDValue &Imm) {
42834282
int64_t ImmVal = CNode->getSExtValue();
42844283
SDLoc DL(N);
42854284
if (ImmVal >= -128 && ImmVal < 128) {
4286-
Imm = CurDAG->getSignedConstant(ImmVal, DL, MVT::i32, /*isTarget=*/true);
4285+
Imm = CurDAG->getSignedTargetConstant(ImmVal, DL, MVT::i32);
42874286
return true;
42884287
}
42894288
}

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9299,8 +9299,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
92999299
// Each tail call may have to adjust the stack by a different amount, so
93009300
// this information must travel along with the operation for eventual
93019301
// consumption by emitEpilogue.
9302-
Ops.push_back(
9303-
DAG.getSignedConstant(FPDiff, DL, MVT::i32, /*isTarget=*/true));
9302+
Ops.push_back(DAG.getSignedTargetConstant(FPDiff, DL, MVT::i32));
93049303
}
93059304

93069305
if (CLI.PAI) {

0 commit comments

Comments
 (0)