Skip to content

Commit e6430d2

Browse files
authored
merge main into amd-staging (llvm#1863)
2 parents 482c605 + 069b73e commit e6430d2

File tree

70 files changed

+520
-277
lines changed

Some content is hidden

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

70 files changed

+520
-277
lines changed

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
147147
if (!Name)
148148
continue;
149149
SymName = *Name;
150-
uint64_t GUID = Function::getGUID(SymName);
150+
uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
151151
FuncStartAddrs[GUID] = F->getAddress();
152152
if (ProfiledOnly && HasProfile)
153153
GuidFilter.insert(GUID);
@@ -173,7 +173,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
173173
const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();
174174
// Checks GUID in GUID2Func and returns it if it's present or null otherwise.
175175
auto checkGUID = [&](StringRef SymName) -> uint64_t {
176-
uint64_t GUID = Function::getGUID(SymName);
176+
uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
177177
if (GUID2Func.find(GUID) == GUID2Func.end())
178178
return 0;
179179
return GUID;
@@ -435,7 +435,7 @@ void PseudoProbeRewriter::encodePseudoProbes() {
435435
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
436436
const uint64_t Addr =
437437
F->isEmitted() ? F->getOutputAddress() : F->getAddress();
438-
FuncStartAddrs[Function::getGUID(
438+
FuncStartAddrs[Function::getGUIDAssumingExternalLinkage(
439439
NameResolver::restore(F->getOneName()))] = Addr;
440440
}
441441
DummyDecoder.buildAddress2ProbeMap(

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -881,20 +881,12 @@ inline bool isDefaultedHelper(const FunctionDecl *FD) {
881881
}
882882

883883
// Metafunction to determine if type T has a member called getDecl.
884-
template <typename Ty>
885-
class has_getDecl {
886-
using yes = char[1];
887-
using no = char[2];
888-
889-
template <typename Inner>
890-
static yes& test(Inner *I, decltype(I->getDecl()) * = nullptr);
891-
892-
template <typename>
893-
static no& test(...);
884+
template <typename T>
885+
using check_has_getDecl = decltype(std::declval<T &>().getDecl());
894886

895-
public:
896-
static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
897-
};
887+
template <typename T>
888+
static constexpr bool has_getDecl =
889+
llvm::is_detected<check_has_getDecl, T>::value;
898890

899891
/// Matches overloaded operators with a specific name.
900892
///

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,25 +1231,6 @@ static const ValueDecl *getValueDecl(const Expr *Exp) {
12311231
return nullptr;
12321232
}
12331233

1234-
namespace {
1235-
1236-
template <typename Ty>
1237-
class has_arg_iterator_range {
1238-
using yes = char[1];
1239-
using no = char[2];
1240-
1241-
template <typename Inner>
1242-
static yes& test(Inner *I, decltype(I->args()) * = nullptr);
1243-
1244-
template <typename>
1245-
static no& test(...);
1246-
1247-
public:
1248-
static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
1249-
};
1250-
1251-
} // namespace
1252-
12531234
bool ThreadSafetyAnalyzer::inCurrentScope(const CapabilityExpr &CapE) {
12541235
const threadSafety::til::SExpr *SExp = CapE.sexpr();
12551236
assert(SExp && "Null expressions should be ignored");

clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ TEST(HasDeclaration, HasDeclarationOfEnumType) {
226226
}
227227

228228
TEST(HasDeclaration, HasGetDeclTraitTest) {
229-
static_assert(internal::has_getDecl<TypedefType>::value,
229+
static_assert(internal::has_getDecl<TypedefType>,
230230
"Expected TypedefType to have a getDecl.");
231-
static_assert(internal::has_getDecl<RecordType>::value,
231+
static_assert(internal::has_getDecl<RecordType>,
232232
"Expected RecordType to have a getDecl.");
233-
static_assert(!internal::has_getDecl<TemplateSpecializationType>::value,
233+
static_assert(!internal::has_getDecl<TemplateSpecializationType>,
234234
"Expected TemplateSpecializationType to *not* have a getDecl.");
235235
}
236236

lldb/tools/debugserver/source/MacOSX/MachProcess.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include "MachVMMemory.h"
3535
#include "PThreadCondition.h"
3636
#include "PThreadEvent.h"
37-
#include "PThreadMutex.h"
3837
#include "RNBContext.h"
3938
#include "ThreadInfo.h"
4039

@@ -413,7 +412,7 @@ class MachProcess {
413412
uint32_t m_stop_count; // A count of many times have we stopped
414413
pthread_t m_stdio_thread; // Thread ID for the thread that watches for child
415414
// process stdio
416-
PThreadMutex m_stdio_mutex; // Multithreaded protection for stdio
415+
std::recursive_mutex m_stdio_mutex; // Multithreaded protection for stdio
417416
std::string m_stdout_data;
418417

419418
bool m_profile_enabled; // A flag to indicate if profiling is enabled
@@ -423,7 +422,7 @@ class MachProcess {
423422
m_profile_scan_type; // Indicates what needs to be profiled
424423
pthread_t
425424
m_profile_thread; // Thread ID for the thread that profiles the inferior
426-
PThreadMutex
425+
std::recursive_mutex
427426
m_profile_data_mutex; // Multithreaded protection for profile info data
428427
std::vector<std::string>
429428
m_profile_data; // Profile data, must be protected by m_profile_data_mutex
@@ -435,15 +434,16 @@ class MachProcess {
435434
// caught when
436435
// listening to the
437436
// exception port
438-
PThreadMutex m_exception_and_signal_mutex; // Multithreaded protection for
439-
// exceptions and signals.
437+
std::recursive_mutex
438+
m_exception_and_signal_mutex; // Multithreaded protection for
439+
// exceptions and signals.
440440

441441
MachThreadList m_thread_list; // A list of threads that is maintained/updated
442442
// after each stop
443443
Genealogy m_activities; // A list of activities that is updated after every
444444
// stop lazily
445445
nub_state_t m_state; // The state of our process
446-
PThreadMutex m_state_mutex; // Multithreaded protection for m_state
446+
std::recursive_mutex m_state_mutex; // Multithreaded protection for m_state
447447
PThreadEvent m_events; // Process related events in the child processes
448448
// lifetime can be waited upon
449449
PThreadEvent m_private_events; // Used to coordinate running and stopping the

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -522,19 +522,17 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
522522
MachProcess::MachProcess()
523523
: m_pid(0), m_cpu_type(0), m_child_stdin(-1), m_child_stdout(-1),
524524
m_child_stderr(-1), m_path(), m_args(), m_task(this),
525-
m_flags(eMachProcessFlagsNone), m_stdio_thread(0),
526-
m_stdio_mutex(PTHREAD_MUTEX_RECURSIVE), m_stdout_data(),
527-
m_profile_enabled(false), m_profile_interval_usec(0), m_profile_thread(0),
528-
m_profile_data_mutex(PTHREAD_MUTEX_RECURSIVE), m_profile_data(),
525+
m_flags(eMachProcessFlagsNone), m_stdio_thread(0), m_stdio_mutex(),
526+
m_stdout_data(), m_profile_enabled(false), m_profile_interval_usec(0),
527+
m_profile_thread(0), m_profile_data_mutex(), m_profile_data(),
529528
m_profile_events(0, eMachProcessProfileCancel), m_thread_actions(),
530-
m_exception_messages(),
531-
m_exception_and_signal_mutex(PTHREAD_MUTEX_RECURSIVE), m_thread_list(),
532-
m_activities(), m_state(eStateUnloaded),
533-
m_state_mutex(PTHREAD_MUTEX_RECURSIVE), m_events(0, kAllEventsMask),
534-
m_private_events(0, kAllEventsMask), m_breakpoints(), m_watchpoints(),
535-
m_name_to_addr_callback(NULL), m_name_to_addr_baton(NULL),
536-
m_image_infos_callback(NULL), m_image_infos_baton(NULL),
537-
m_sent_interrupt_signo(0), m_auto_resume_signo(0), m_did_exec(false),
529+
m_exception_messages(), m_exception_and_signal_mutex(), m_thread_list(),
530+
m_activities(), m_state(eStateUnloaded), m_state_mutex(),
531+
m_events(0, kAllEventsMask), m_private_events(0, kAllEventsMask),
532+
m_breakpoints(), m_watchpoints(), m_name_to_addr_callback(NULL),
533+
m_name_to_addr_baton(NULL), m_image_infos_callback(NULL),
534+
m_image_infos_baton(NULL), m_sent_interrupt_signo(0),
535+
m_auto_resume_signo(0), m_did_exec(false),
538536
m_dyld_process_info_create(nullptr),
539537
m_dyld_process_info_for_each_image(nullptr),
540538
m_dyld_process_info_release(nullptr),
@@ -577,7 +575,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary *options,
577575

578576
nub_state_t MachProcess::GetState() {
579577
// If any other threads access this we will need a mutex for it
580-
PTHREAD_MUTEX_LOCKER(locker, m_state_mutex);
578+
std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
581579
return m_state;
582580
}
583581

@@ -1279,7 +1277,7 @@ static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) {
12791277

12801278
// Scope for mutex locker
12811279
{
1282-
PTHREAD_MUTEX_LOCKER(locker, m_state_mutex);
1280+
std::lock_guard<std::recursive_mutex> guard(m_state_mutex);
12831281
const nub_state_t old_state = m_state;
12841282

12851283
if (old_state == eStateExited) {
@@ -1338,7 +1336,7 @@ static bool mach_header_validity_test(uint32_t magic, uint32_t cputype) {
13381336
m_stop_count = 0;
13391337
m_thread_list.Clear();
13401338
{
1341-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
1339+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
13421340
m_exception_messages.clear();
13431341
m_sent_interrupt_signo = 0;
13441342
m_auto_resume_signo = 0;
@@ -1578,7 +1576,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
15781576
bool MachProcess::Interrupt() {
15791577
nub_state_t state = GetState();
15801578
if (IsRunning(state)) {
1581-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
1579+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
15821580
if (m_sent_interrupt_signo == 0) {
15831581
m_sent_interrupt_signo = SIGSTOP;
15841582
if (Signal(m_sent_interrupt_signo)) {
@@ -1736,7 +1734,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
17361734
m_thread_actions.Append(thread_action);
17371735
m_thread_actions.SetDefaultThreadActionIfNeeded(eStateRunning, 0);
17381736

1739-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
1737+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
17401738

17411739
ReplyToAllExceptions();
17421740
}
@@ -1862,7 +1860,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
18621860
}
18631861

18641862
void MachProcess::ReplyToAllExceptions() {
1865-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
1863+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
18661864
if (!m_exception_messages.empty()) {
18671865
MachException::Message::iterator pos;
18681866
MachException::Message::iterator begin = m_exception_messages.begin();
@@ -1896,7 +1894,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
18961894
}
18971895
}
18981896
void MachProcess::PrivateResume() {
1899-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
1897+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
19001898

19011899
m_auto_resume_signo = m_sent_interrupt_signo;
19021900
if (m_auto_resume_signo)
@@ -2298,7 +2296,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
22982296
// data has already been copied.
22992297
void MachProcess::ExceptionMessageReceived(
23002298
const MachException::Message &exceptionMessage) {
2301-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
2299+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
23022300

23032301
if (m_exception_messages.empty())
23042302
m_task.Suspend();
@@ -2312,7 +2310,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
23122310

23132311
task_t MachProcess::ExceptionMessageBundleComplete() {
23142312
// We have a complete bundle of exceptions for our child process.
2315-
PTHREAD_MUTEX_LOCKER(locker, m_exception_and_signal_mutex);
2313+
std::lock_guard<std::recursive_mutex> guard(m_exception_and_signal_mutex);
23162314
DNBLogThreadedIf(LOG_EXCEPTIONS, "%s: %llu exception messages.",
23172315
__PRETTY_FUNCTION__, (uint64_t)m_exception_messages.size());
23182316
bool auto_resume = false;
@@ -2495,7 +2493,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
24952493
void MachProcess::AppendSTDOUT(char *s, size_t len) {
24962494
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (<%llu> %s) ...", __FUNCTION__,
24972495
(uint64_t)len, s);
2498-
PTHREAD_MUTEX_LOCKER(locker, m_stdio_mutex);
2496+
std::lock_guard<std::recursive_mutex> guard(m_stdio_mutex);
24992497
m_stdout_data.append(s, len);
25002498
m_events.SetEvents(eEventStdioAvailable);
25012499

@@ -2506,7 +2504,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
25062504
size_t MachProcess::GetAvailableSTDOUT(char *buf, size_t buf_size) {
25072505
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__,
25082506
static_cast<void *>(buf), (uint64_t)buf_size);
2509-
PTHREAD_MUTEX_LOCKER(locker, m_stdio_mutex);
2507+
std::lock_guard<std::recursive_mutex> guard(m_stdio_mutex);
25102508
size_t bytes_available = m_stdout_data.size();
25112509
if (bytes_available > 0) {
25122510
if (bytes_available > buf_size) {
@@ -2733,7 +2731,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
27332731

27342732
void MachProcess::SignalAsyncProfileData(const char *info) {
27352733
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (%s) ...", __FUNCTION__, info);
2736-
PTHREAD_MUTEX_LOCKER(locker, m_profile_data_mutex);
2734+
std::lock_guard<std::recursive_mutex> guard(m_profile_data_mutex);
27372735
m_profile_data.push_back(info);
27382736
m_events.SetEvents(eEventProfileDataAvailable);
27392737

@@ -2744,7 +2742,7 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
27442742
size_t MachProcess::GetAsyncProfileData(char *buf, size_t buf_size) {
27452743
DNBLogThreadedIf(LOG_PROCESS, "MachProcess::%s (&%p[%llu]) ...", __FUNCTION__,
27462744
static_cast<void *>(buf), (uint64_t)buf_size);
2747-
PTHREAD_MUTEX_LOCKER(locker, m_profile_data_mutex);
2745+
std::lock_guard<std::recursive_mutex> guard(m_profile_data_mutex);
27482746
if (m_profile_data.empty())
27492747
return 0;
27502748

llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class DuplicateDefinitionInSummary
7777

7878
void log(raw_ostream &OS) const override {
7979
OS << "Duplicate symbol for global value '" << GlobalValueName
80-
<< "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
80+
<< "' (GUID: "
81+
<< GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
82+
<< ") in:\n";
8183
for (const std::string &Path : ModulePaths) {
8284
OS << " " << Path << "\n";
8385
}
@@ -110,8 +112,9 @@ class DefinitionNotFoundInSummary
110112
}
111113

112114
void log(raw_ostream &OS) const override {
113-
OS << "No symbol for global value '" << GlobalValueName
114-
<< "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
115+
OS << "No symbol for global value '" << GlobalValueName << "' (GUID: "
116+
<< GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
117+
<< ") in:\n";
115118
for (const std::string &Path : ModulePaths) {
116119
OS << " " << Path << "\n";
117120
}
@@ -135,7 +138,8 @@ char DefinitionNotFoundInSummary::ID = 0;
135138
Expected<StringRef> getMainModulePath(StringRef FunctionName,
136139
ModuleSummaryIndex &Index) {
137140
// Summaries use unmangled names.
138-
GlobalValue::GUID G = GlobalValue::getGUID(FunctionName);
141+
GlobalValue::GUID G =
142+
GlobalValue::getGUIDAssumingExternalLinkage(FunctionName);
139143
ValueInfo VI = Index.getValueInfo(G);
140144

141145
// We need a unique definition, otherwise don't try further.

llvm/include/llvm/CodeGen/ByteProvider.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef LLVM_CODEGEN_BYTEPROVIDER_H
1818
#define LLVM_CODEGEN_BYTEPROVIDER_H
1919

20+
#include "llvm/ADT/STLExtras.h"
2021
#include "llvm/Support/DataTypes.h"
2122
#include <optional>
2223
#include <type_traits>
@@ -35,22 +36,14 @@ template <typename ISelOp> class ByteProvider {
3536

3637
// TODO -- use constraint in c++20
3738
// Does this type correspond with an operation in selection DAG
38-
template <typename T> class is_op {
39-
private:
40-
using yes = std::true_type;
41-
using no = std::false_type;
39+
// Only allow classes with member function getOpcode
40+
template <typename U>
41+
using check_has_getOpcode =
42+
decltype(std::declval<std::remove_pointer_t<U> &>().getOpcode());
4243

43-
// Only allow classes with member function getOpcode
44-
template <typename U>
45-
static auto test(int) -> decltype(std::declval<U>().getOpcode(), yes());
46-
47-
template <typename> static no test(...);
48-
49-
public:
50-
using remove_pointer_t = typename std::remove_pointer<T>::type;
51-
static constexpr bool value =
52-
std::is_same<decltype(test<remove_pointer_t>(0)), yes>::value;
53-
};
44+
template <typename U>
45+
static constexpr bool has_getOpcode =
46+
is_detected<check_has_getOpcode, U>::value;
5447

5548
public:
5649
// For constant zero providers Src is set to nullopt. For actual providers
@@ -66,7 +59,7 @@ template <typename ISelOp> class ByteProvider {
6659

6760
static ByteProvider getSrc(std::optional<ISelOp> Val, int64_t ByteOffset,
6861
int64_t VectorOffset) {
69-
static_assert(is_op<ISelOp>().value,
62+
static_assert(has_getOpcode<ISelOp>,
7063
"ByteProviders must contain an operation in selection DAG.");
7164
return ByteProvider(Val, ByteOffset, VectorOffset);
7265
}

llvm/include/llvm/CodeGen/PBQP/Math.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ using PBQPNum = float;
2525

2626
/// PBQP Vector class.
2727
class Vector {
28-
friend hash_code hash_value(const Vector &);
29-
3028
public:
3129
/// Construct a PBQP vector of the given size.
3230
explicit Vector(unsigned Length) : Data(Length) {}
@@ -96,7 +94,7 @@ class Vector {
9694
inline hash_code hash_value(const Vector &V) {
9795
const unsigned *VBegin = reinterpret_cast<const unsigned *>(V.begin());
9896
const unsigned *VEnd = reinterpret_cast<const unsigned *>(V.end());
99-
return hash_combine(V.Data.size(), hash_combine_range(VBegin, VEnd));
97+
return hash_combine(V.getLength(), hash_combine_range(VBegin, VEnd));
10098
}
10199

102100
/// Output a textual representation of the given vector on the given

0 commit comments

Comments
 (0)