Skip to content

Commit 7488a44

Browse files
Merge commit '132d711554cbb3db0b0efd1e88d2acb9278b6be9' into pulldown-ww29
2 parents 56d21c0 + 132d711 commit 7488a44

File tree

1,104 files changed

+101053
-19958
lines changed

Some content is hidden

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

1,104 files changed

+101053
-19958
lines changed

bolt/runtime/common.h

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,49 @@ typedef int int32_t;
7676
"pop %%rbx\n" \
7777
"pop %%rax\n"
7878

79+
// Functions that are required by freestanding environment. Compiler may
80+
// generate calls to these implicitly.
81+
extern "C" {
82+
void *memcpy(void *Dest, const void *Src, size_t Len) {
83+
uint8_t *d = static_cast<uint8_t *>(Dest);
84+
const uint8_t *s = static_cast<const uint8_t *>(Src);
85+
while (Len--)
86+
*d++ = *s++;
87+
return Dest;
88+
}
89+
90+
void *memmove(void *Dest, const void *Src, size_t Len) {
91+
uint8_t *d = static_cast<uint8_t *>(Dest);
92+
const uint8_t *s = static_cast<const uint8_t *>(Src);
93+
if (d < s) {
94+
while (Len--)
95+
*d++ = *s++;
96+
} else {
97+
s += Len - 1;
98+
d += Len - 1;
99+
while (Len--)
100+
*d-- = *s--;
101+
}
102+
103+
return Dest;
104+
}
105+
106+
void memset(char *Buf, char C, uint32_t Size) {
107+
for (int I = 0; I < Size; ++I)
108+
*Buf++ = C;
109+
}
110+
111+
int memcmp(const void *s1, const void *s2, size_t n) {
112+
const uint8_t *c1 = static_cast<const uint8_t *>(s1);
113+
const uint8_t *c2 = static_cast<const uint8_t *>(s2);
114+
for (; n--; c1++, c2++) {
115+
if (*c1 != *c2)
116+
return *c1 < *c2 ? -1 : 1;
117+
}
118+
return 0;
119+
}
120+
} // extern "C"
121+
79122
// Anonymous namespace covering everything but our library entry point
80123
namespace {
81124

@@ -187,7 +230,7 @@ uint64_t __exit(uint64_t code) {
187230
}
188231

189232
// Helper functions for writing strings to the .fdata file. We intentionally
190-
// avoid using libc names (lowercase memset) to make it clear it is our impl.
233+
// avoid using libc names to make it clear it is our impl.
191234

192235
/// Write number Num using Base to the buffer in OutBuf, returns a pointer to
193236
/// the end of the string.
@@ -231,19 +274,6 @@ int strnCmp(const char *Str1, const char *Str2, size_t Num) {
231274
return *(unsigned char *)Str1 - *(unsigned char *)Str2;
232275
}
233276

234-
void memSet(char *Buf, char C, uint32_t Size) {
235-
for (int I = 0; I < Size; ++I)
236-
*Buf++ = C;
237-
}
238-
239-
void *memCpy(void *Dest, const void *Src, size_t Len) {
240-
char *d = static_cast<char *>(Dest);
241-
const char *s = static_cast<const char *>(Src);
242-
while (Len--)
243-
*d++ = *s++;
244-
return Dest;
245-
}
246-
247277
uint32_t strLen(const char *Str) {
248278
uint32_t Size = 0;
249279
while (*Str++)
@@ -468,17 +498,12 @@ void assert(bool Assertion, const char *Msg) {
468498
reportError(Buf, Ptr - Buf);
469499
}
470500

471-
/// 1B mutex accessed by lock xchg
472501
class Mutex {
473502
volatile bool InUse{false};
474503

475504
public:
476-
bool acquire() {
477-
bool Result = true;
478-
asm volatile("lock; xchg %0, %1" : "+m"(InUse), "=r"(Result) : : "cc");
479-
return !Result;
480-
}
481-
void release() { InUse = false; }
505+
bool acquire() { return !__atomic_test_and_set(&InUse, __ATOMIC_ACQUIRE); }
506+
void release() { __atomic_clear(&InUse, __ATOMIC_RELEASE); }
482507
};
483508

484509
/// RAII wrapper for Mutex

bolt/runtime/hugify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void hugify_for_old_kernel(uint8_t *from, uint8_t *to) {
5959
#endif
6060

6161
// Copy the hot code to a temproary location.
62-
memCpy(mem, from, size);
62+
memcpy(mem, from, size);
6363

6464
// Maps out the existing hot code.
6565
if (__mmap(reinterpret_cast<uint64_t>(from), size,
@@ -77,7 +77,7 @@ static void hugify_for_old_kernel(uint8_t *from, uint8_t *to) {
7777
}
7878

7979
// Copy the hot code back.
80-
memCpy(from, mem, size);
80+
memcpy(from, mem, size);
8181

8282
// Change permission back to read-only, ignore failure
8383
__mprotect(from, size, PROT_READ | PROT_EXEC);

bolt/runtime/instr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ BumpPtrAllocator GlobalAlloc;
224224
void *operator new(size_t Sz, BumpPtrAllocator &A) { return A.allocate(Sz); }
225225
void *operator new(size_t Sz, BumpPtrAllocator &A, char C) {
226226
auto *Ptr = reinterpret_cast<char *>(A.allocate(Sz));
227-
memSet(Ptr, C, Sz);
227+
memset(Ptr, C, Sz);
228228
return Ptr;
229229
}
230230
void *operator new[](size_t Sz, BumpPtrAllocator &A) {
231231
return A.allocate(Sz);
232232
}
233233
void *operator new[](size_t Sz, BumpPtrAllocator &A, char C) {
234234
auto *Ptr = reinterpret_cast<char *>(A.allocate(Sz));
235-
memSet(Ptr, C, Sz);
235+
memset(Ptr, C, Sz);
236236
return Ptr;
237237
}
238238
// Only called during exception unwinding (useless). We must manually dealloc.
@@ -289,6 +289,7 @@ class SimpleHashTable {
289289
/// Traverses all elements in the table
290290
template <typename... Args>
291291
void forEachElement(void (*Callback)(MapEntry &, Args...), Args... args) {
292+
Lock L(M);
292293
if (!TableRoot)
293294
return;
294295
return forEachElement(Callback, InitialSize, TableRoot, args...);
@@ -378,7 +379,6 @@ template <typename T> void resetIndCallCounter(T &Entry) {
378379

379380
template <typename T, uint32_t X, uint32_t Y>
380381
void SimpleHashTable<T, X, Y>::resetCounters() {
381-
Lock L(M);
382382
forEachElement(resetIndCallCounter);
383383
}
384384

@@ -1438,7 +1438,7 @@ int openProfile() {
14381438
/// Where 0xdeadbeef is this function address and PROCESSNAME your binary file
14391439
/// name.
14401440
extern "C" void __bolt_instr_clear_counters() {
1441-
memSet(reinterpret_cast<char *>(__bolt_instr_locations), 0,
1441+
memset(reinterpret_cast<char *>(__bolt_instr_locations), 0,
14421442
__bolt_num_counters * 8);
14431443
for (int I = 0; I < __bolt_instr_num_ind_calls; ++I)
14441444
GlobalIndCallCounters[I].resetCounters();

clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ static bool mayShadow(const NamedDecl *ND0, const NamedDecl *ND1) {
127127
const DeclContext *DC1 = ND1->getDeclContext()->getPrimaryContext();
128128

129129
if (const CXXRecordDecl *RD0 = dyn_cast<CXXRecordDecl>(DC0)) {
130-
if (ND1->getAccess() != AS_private && isMemberOf(ND1, RD0))
130+
RD0 = RD0->getDefinition();
131+
if (RD0 && ND1->getAccess() != AS_private && isMemberOf(ND1, RD0))
131132
return true;
132133
}
133134
if (const CXXRecordDecl *RD1 = dyn_cast<CXXRecordDecl>(DC1)) {
134-
if (ND0->getAccess() != AS_private && isMemberOf(ND0, RD1))
135+
RD1 = RD1->getDefinition();
136+
if (RD1 && ND0->getAccess() != AS_private && isMemberOf(ND0, RD1))
135137
return true;
136138
}
137139

0 commit comments

Comments
 (0)