Skip to content

Commit 69405f0

Browse files
authored
merge main into amd-staging (llvm#2111)
2 parents a0dd2dd + bb8b79d commit 69405f0

Some content is hidden

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

44 files changed

+619
-741
lines changed

clang/include/clang/AST/DeclTemplate.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,16 +781,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
781781
bool loadLazySpecializationsImpl(llvm::ArrayRef<TemplateArgument> Args,
782782
TemplateParameterList *TPL = nullptr) const;
783783

784-
template <class EntryType, typename ...ProfileArguments>
785-
typename SpecEntryTraits<EntryType>::DeclType*
784+
template <class EntryType, typename... ProfileArguments>
785+
typename SpecEntryTraits<EntryType>::DeclType *
786786
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
787-
void *&InsertPos, ProfileArguments &&...ProfileArgs);
787+
void *&InsertPos, ProfileArguments... ProfileArgs);
788788

789789
template <class EntryType, typename... ProfileArguments>
790790
typename SpecEntryTraits<EntryType>::DeclType *
791791
findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
792-
void *&InsertPos,
793-
ProfileArguments &&...ProfileArgs);
792+
void *&InsertPos, ProfileArguments... ProfileArgs);
794793

795794
template <class Derived, class EntryType>
796795
void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,

clang/lib/AST/DeclTemplate.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,11 @@ template <class EntryType, typename... ProfileArguments>
382382
typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
383383
RedeclarableTemplateDecl::findSpecializationLocally(
384384
llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
385-
ProfileArguments &&...ProfileArgs) {
385+
ProfileArguments... ProfileArgs) {
386386
using SETraits = RedeclarableTemplateDecl::SpecEntryTraits<EntryType>;
387387

388388
llvm::FoldingSetNodeID ID;
389-
EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)...,
390-
getASTContext());
389+
EntryType::Profile(ID, ProfileArgs..., getASTContext());
391390
EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
392391
return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
393392
}
@@ -396,18 +395,15 @@ template <class EntryType, typename... ProfileArguments>
396395
typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
397396
RedeclarableTemplateDecl::findSpecializationImpl(
398397
llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
399-
ProfileArguments &&...ProfileArgs) {
398+
ProfileArguments... ProfileArgs) {
400399

401-
if (auto *Found = findSpecializationLocally(
402-
Specs, InsertPos, std::forward<ProfileArguments>(ProfileArgs)...))
400+
if (auto *Found = findSpecializationLocally(Specs, InsertPos, ProfileArgs...))
403401
return Found;
404402

405-
if (!loadLazySpecializationsImpl(
406-
std::forward<ProfileArguments>(ProfileArgs)...))
403+
if (!loadLazySpecializationsImpl(ProfileArgs...))
407404
return nullptr;
408405

409-
return findSpecializationLocally(
410-
Specs, InsertPos, std::forward<ProfileArguments>(ProfileArgs)...);
406+
return findSpecializationLocally(Specs, InsertPos, ProfileArgs...);
411407
}
412408

413409
template<class Derived, class EntryType>

clang/test/AST/ast-dump-openmp-begin-declare-variant_decl_1.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s | FileCheck %s
22
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -verify -ast-dump %s -x c++| FileCheck %s
33
// expected-no-diagnostics
4-
// XFAIL: *
5-
64
// FIXME: We have to improve the warnings here as nothing is impacted by the declare variant.
75
int also_before(void) {
86
return 0;
@@ -11,10 +9,10 @@ int also_before(void) {
119
#pragma omp begin declare variant match(device={kind(cpu)})
1210
int also_before(void);
1311
#pragma omp end declare variant
14-
#pragma omp begin declare variant match(implementation={vendor(score(100):llvm)})
12+
#pragma omp begin declare variant match(implementation={vendor(score(100):amd)})
1513
int also_after(void);
1614
#pragma omp end declare variant
17-
#pragma omp begin declare variant match(implementation={vendor(score(0):llvm)})
15+
#pragma omp begin declare variant match(implementation={vendor(score(0):amd)})
1816
int also_before(void);
1917
#pragma omp end declare variant
2018

@@ -29,7 +27,7 @@ int test(void) {
2927

3028
// Make sure:
3129
// - we do see the ast nodes for the cpu kind
32-
// - we do see the ast nodes for the llvm vendor
30+
// - we do see the ast nodes for the amd vendor
3331
// - we pick the right callees
3432

3533
// CHECK: |-FunctionDecl [[ADDR_0:0x[a-z0-9]*]] <{{.*}}, line:7:1> line:5:5 used also_before 'int ({{.*}})'

lldb/source/Host/windows/PipeWindows.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ Status PipeWindows::CreateNew(llvm::StringRef name,
8888
std::string pipe_path = g_pipe_name_prefix.str();
8989
pipe_path.append(name.str());
9090

91-
SECURITY_ATTRIBUTES sa{sizeof(SECURITY_ATTRIBUTES), 0,
92-
child_process_inherit ? TRUE : FALSE};
91+
// We always create inheritable handles, but we won't pass them to a child
92+
// process unless explicitly requested (cf. ProcessLauncherWindows.cpp).
93+
SECURITY_ATTRIBUTES sa{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
9394

9495
// Always open for overlapped i/o. We implement blocking manually in Read
9596
// and Write.
@@ -165,8 +166,9 @@ Status PipeWindows::OpenNamedPipe(llvm::StringRef name,
165166

166167
assert(is_read ? !CanRead() : !CanWrite());
167168

168-
SECURITY_ATTRIBUTES attributes{sizeof(SECURITY_ATTRIBUTES), 0,
169-
child_process_inherit ? TRUE : FALSE};
169+
// We always create inheritable handles, but we won't pass them to a child
170+
// process unless explicitly requested (cf. ProcessLauncherWindows.cpp).
171+
SECURITY_ATTRIBUTES attributes{sizeof(SECURITY_ATTRIBUTES), 0, TRUE};
170172

171173
std::string pipe_path = g_pipe_name_prefix.str();
172174
pipe_path.append(name.str());

lldb/source/Host/windows/ProcessLauncherWindows.cpp

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "lldb/Host/HostProcess.h"
1111
#include "lldb/Host/ProcessLaunchInfo.h"
1212

13+
#include "llvm/ADT/ScopeExit.h"
1314
#include "llvm/ADT/SmallVector.h"
1415
#include "llvm/Support/ConvertUTF.h"
1516
#include "llvm/Support/Program.h"
@@ -65,14 +66,23 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
6566

6667
std::string executable;
6768
std::vector<char> environment;
68-
STARTUPINFO startupinfo = {};
69+
STARTUPINFOEX startupinfoex = {};
70+
STARTUPINFO &startupinfo = startupinfoex.StartupInfo;
6971
PROCESS_INFORMATION pi = {};
7072

7173
HANDLE stdin_handle = GetStdioHandle(launch_info, STDIN_FILENO);
7274
HANDLE stdout_handle = GetStdioHandle(launch_info, STDOUT_FILENO);
7375
HANDLE stderr_handle = GetStdioHandle(launch_info, STDERR_FILENO);
74-
75-
startupinfo.cb = sizeof(startupinfo);
76+
auto close_handles = llvm::make_scope_exit([&] {
77+
if (stdin_handle)
78+
::CloseHandle(stdin_handle);
79+
if (stdout_handle)
80+
::CloseHandle(stdout_handle);
81+
if (stderr_handle)
82+
::CloseHandle(stderr_handle);
83+
});
84+
85+
startupinfo.cb = sizeof(startupinfoex);
7686
startupinfo.dwFlags |= STARTF_USESTDHANDLES;
7787
startupinfo.hStdError =
7888
stderr_handle ? stderr_handle : ::GetStdHandle(STD_ERROR_HANDLE);
@@ -81,6 +91,48 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
8191
startupinfo.hStdOutput =
8292
stdout_handle ? stdout_handle : ::GetStdHandle(STD_OUTPUT_HANDLE);
8393

94+
std::vector<HANDLE> inherited_handles;
95+
if (startupinfo.hStdError)
96+
inherited_handles.push_back(startupinfo.hStdError);
97+
if (startupinfo.hStdInput)
98+
inherited_handles.push_back(startupinfo.hStdInput);
99+
if (startupinfo.hStdOutput)
100+
inherited_handles.push_back(startupinfo.hStdOutput);
101+
102+
size_t attributelist_size = 0;
103+
InitializeProcThreadAttributeList(/*lpAttributeList=*/nullptr,
104+
/*dwAttributeCount=*/1, /*dwFlags=*/0,
105+
&attributelist_size);
106+
107+
startupinfoex.lpAttributeList =
108+
static_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(malloc(attributelist_size));
109+
auto free_attributelist =
110+
llvm::make_scope_exit([&] { free(startupinfoex.lpAttributeList); });
111+
if (!InitializeProcThreadAttributeList(startupinfoex.lpAttributeList,
112+
/*dwAttributeCount=*/1, /*dwFlags=*/0,
113+
&attributelist_size)) {
114+
error = Status(::GetLastError(), eErrorTypeWin32);
115+
return HostProcess();
116+
}
117+
auto delete_attributelist = llvm::make_scope_exit(
118+
[&] { DeleteProcThreadAttributeList(startupinfoex.lpAttributeList); });
119+
for (size_t i = 0; i < launch_info.GetNumFileActions(); ++i) {
120+
const FileAction *act = launch_info.GetFileActionAtIndex(i);
121+
if (act->GetAction() == FileAction::eFileActionDuplicate &&
122+
act->GetFD() == act->GetActionArgument())
123+
inherited_handles.push_back(reinterpret_cast<HANDLE>(act->GetFD()));
124+
}
125+
if (!inherited_handles.empty()) {
126+
if (!UpdateProcThreadAttribute(
127+
startupinfoex.lpAttributeList, /*dwFlags=*/0,
128+
PROC_THREAD_ATTRIBUTE_HANDLE_LIST, inherited_handles.data(),
129+
inherited_handles.size() * sizeof(HANDLE),
130+
/*lpPreviousValue=*/nullptr, /*lpReturnSize=*/nullptr)) {
131+
error = Status(::GetLastError(), eErrorTypeWin32);
132+
return HostProcess();
133+
}
134+
}
135+
84136
const char *hide_console_var =
85137
getenv("LLDB_LAUNCH_INFERIORS_WITHOUT_CONSOLE");
86138
if (hide_console_var &&
@@ -89,7 +141,8 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
89141
startupinfo.wShowWindow = SW_HIDE;
90142
}
91143

92-
DWORD flags = CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT;
144+
DWORD flags = CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT |
145+
EXTENDED_STARTUPINFO_PRESENT;
93146
if (launch_info.GetFlags().Test(eLaunchFlagDebug))
94147
flags |= DEBUG_ONLY_THIS_PROCESS;
95148

@@ -114,9 +167,10 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
114167
WCHAR *pwcommandLine = wcommandLine.empty() ? nullptr : &wcommandLine[0];
115168

116169
BOOL result = ::CreateProcessW(
117-
wexecutable.c_str(), pwcommandLine, NULL, NULL, TRUE, flags, env_block,
170+
wexecutable.c_str(), pwcommandLine, NULL, NULL,
171+
/*bInheritHandles=*/!inherited_handles.empty(), flags, env_block,
118172
wworkingDirectory.size() == 0 ? NULL : wworkingDirectory.c_str(),
119-
&startupinfo, &pi);
173+
reinterpret_cast<STARTUPINFO *>(&startupinfoex), &pi);
120174

121175
if (!result) {
122176
// Call GetLastError before we make any other system calls.
@@ -131,13 +185,6 @@ ProcessLauncherWindows::LaunchProcess(const ProcessLaunchInfo &launch_info,
131185
::CloseHandle(pi.hThread);
132186
}
133187

134-
if (stdin_handle)
135-
::CloseHandle(stdin_handle);
136-
if (stdout_handle)
137-
::CloseHandle(stdout_handle);
138-
if (stderr_handle)
139-
::CloseHandle(stderr_handle);
140-
141188
if (!result)
142189
return HostProcess();
143190

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
924924
debugserver_args.AppendArgument(fd_arg.GetString());
925925
// Send "pass_comm_fd" down to the inferior so it can use it to
926926
// communicate back with this process. Ignored on Windows.
927-
#ifndef _WIN32
928927
launch_info.AppendDuplicateFileAction((int)pass_comm_fd, (int)pass_comm_fd);
929-
#endif
930928
}
931929

932930
// use native registers, not the GDB registers

lldb/tools/lldb-server/lldb-platform.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,8 @@ static Status spawn_process(const char *progname, const FileSpec &prog,
274274
self_args.AppendArgument(llvm::StringRef("platform"));
275275
self_args.AppendArgument(llvm::StringRef("--child-platform-fd"));
276276
self_args.AppendArgument(llvm::to_string(shared_socket.GetSendableFD()));
277-
#ifndef _WIN32
278277
launch_info.AppendDuplicateFileAction((int)shared_socket.GetSendableFD(),
279278
(int)shared_socket.GetSendableFD());
280-
#endif
281279
if (gdb_port) {
282280
self_args.AppendArgument(llvm::StringRef("--gdbserver-port"));
283281
self_args.AppendArgument(llvm::to_string(gdb_port));

lldb/unittests/Host/HostTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ TEST(Host, LaunchProcessSetsArgv0) {
9090
ASSERT_THAT(exit_status.get_future().get(), 0);
9191
}
9292

93-
#ifdef LLVM_ON_UNIX
9493
TEST(Host, LaunchProcessDuplicatesHandle) {
9594
static constexpr llvm::StringLiteral test_msg("Hello subprocess!");
9695

@@ -130,4 +129,3 @@ TEST(Host, LaunchProcessDuplicatesHandle) {
130129
ASSERT_THAT_EXPECTED(bytes_read, llvm::Succeeded());
131130
ASSERT_EQ(llvm::StringRef(msg, *bytes_read), test_msg);
132131
}
133-
#endif

llvm/include/llvm/Analysis/VecFuncs.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ TLI_DEFINE_VECFUNC("erfc", "Sleef_erfcdx_u15rvvm2", SCALABLE(2), NOMASK, "_ZGVr
954954
TLI_DEFINE_VECFUNC("erfcf", "Sleef_erfcfx_u15rvvm2", SCALABLE(4), NOMASK, "_ZGVrNxv")
955955

956956
TLI_DEFINE_VECFUNC("exp", "Sleef_expdx_u10rvvm2", SCALABLE(2), NOMASK, "_ZGVrNxv")
957-
TLI_DEFINE_VECFUNC("llvm.exp.f64", "Sleef_expdx_u10rvvm2", SCALABLE(4), NOMASK, "_ZGVrNxv")
957+
TLI_DEFINE_VECFUNC("llvm.exp.f64", "Sleef_expdx_u10rvvm2", SCALABLE(2), NOMASK, "_ZGVrNxv")
958958
TLI_DEFINE_VECFUNC("expf", "Sleef_expfx_u10rvvm2", SCALABLE(4), NOMASK, "_ZGVrNxv")
959959
TLI_DEFINE_VECFUNC("llvm.exp.f32", "Sleef_expfx_u10rvvm2", SCALABLE(4), NOMASK, "_ZGVrNxv")
960960

llvm/include/llvm/DebugInfo/GSYM/FunctionInfo.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,8 @@ inline bool operator!=(const FunctionInfo &LHS, const FunctionInfo &RHS) {
234234
/// the GSYM file.
235235
inline bool operator<(const FunctionInfo &LHS, const FunctionInfo &RHS) {
236236
// First sort by address range
237-
if (LHS.Range != RHS.Range)
238-
return LHS.Range < RHS.Range;
239-
if (LHS.Inline == RHS.Inline)
240-
return LHS.OptLineTable < RHS.OptLineTable;
241-
return LHS.Inline < RHS.Inline;
237+
return std::tie(LHS.Range, LHS.Inline, LHS.OptLineTable) <
238+
std::tie(RHS.Range, RHS.Inline, RHS.OptLineTable);
242239
}
243240

244241
raw_ostream &operator<<(raw_ostream &OS, const FunctionInfo &R);

llvm/include/llvm/MC/MCContext.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,9 @@ class MCContext {
262262
SelectionKey(SelectionKey), UniqueID(UniqueID) {}
263263

264264
bool operator<(const COFFSectionKey &Other) const {
265-
if (SectionName != Other.SectionName)
266-
return SectionName < Other.SectionName;
267-
if (GroupName != Other.GroupName)
268-
return GroupName < Other.GroupName;
269-
if (SelectionKey != Other.SelectionKey)
270-
return SelectionKey < Other.SelectionKey;
271-
return UniqueID < Other.UniqueID;
265+
return std::tie(SectionName, GroupName, SelectionKey, UniqueID) <
266+
std::tie(Other.SectionName, Other.GroupName, Other.SelectionKey,
267+
Other.UniqueID);
272268
}
273269
};
274270

@@ -282,11 +278,8 @@ class MCContext {
282278
: SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {}
283279

284280
bool operator<(const WasmSectionKey &Other) const {
285-
if (SectionName != Other.SectionName)
286-
return SectionName < Other.SectionName;
287-
if (GroupName != Other.GroupName)
288-
return GroupName < Other.GroupName;
289-
return UniqueID < Other.UniqueID;
281+
return std::tie(SectionName, GroupName, UniqueID) <
282+
std::tie(Other.SectionName, Other.GroupName, Other.UniqueID);
290283
}
291284
};
292285

llvm/lib/Analysis/DXILResource.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,7 @@ void DXILResourceBindingInfo::populate(Module &M, DXILResourceTypeMap &DRTM) {
955955
// for each binding type and used spaces. Bindings are sorted by resource
956956
// class, space, and lower bound register slot.
957957
BindingSpaces *BS = &SRVSpaces;
958-
for (unsigned I = 0, E = Bindings.size(); I != E; ++I) {
959-
Binding &B = Bindings[I];
960-
958+
for (const Binding &B : Bindings) {
961959
if (BS->RC != B.RC)
962960
// move to the next resource class spaces
963961
BS = &getBindingSpaces(B.RC);

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,11 +4462,14 @@ static SDValue foldSetCCWithFunnelShift(EVT VT, SDValue N0, SDValue N1,
44624462

44634463
unsigned BitWidth = N0.getScalarValueSizeInBits();
44644464
auto *ShAmtC = isConstOrConstSplat(N0.getOperand(2));
4465-
if (!ShAmtC || ShAmtC->getAPIntValue().uge(BitWidth))
4465+
if (!ShAmtC)
4466+
return SDValue();
4467+
4468+
uint64_t ShAmt = ShAmtC->getAPIntValue().urem(BitWidth);
4469+
if (ShAmt == 0)
44664470
return SDValue();
44674471

44684472
// Canonicalize fshr as fshl to reduce pattern-matching.
4469-
unsigned ShAmt = ShAmtC->getZExtValue();
44704473
if (N0.getOpcode() == ISD::FSHR)
44714474
ShAmt = BitWidth - ShAmt;
44724475

llvm/lib/ObjCopy/Archive.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include "llvm/Support/FileOutputBuffer.h"
1515
#include "llvm/Support/SmallVectorMemoryBuffer.h"
1616

17-
namespace llvm {
18-
namespace objcopy {
19-
17+
using namespace llvm;
18+
using namespace llvm::objcopy;
2019
using namespace llvm::object;
2120

2221
Expected<std::vector<NewArchiveMember>>
23-
createNewArchiveMembers(const MultiFormatConfig &Config, const Archive &Ar) {
22+
objcopy::createNewArchiveMembers(const MultiFormatConfig &Config,
23+
const Archive &Ar) {
2424
std::vector<NewArchiveMember> NewArchiveMembers;
2525
Error Err = Error::success();
2626
for (const Archive::Child &Child : Ar.children(Err)) {
@@ -94,8 +94,8 @@ static Error deepWriteArchive(StringRef ArcName,
9494
return Error::success();
9595
}
9696

97-
Error executeObjcopyOnArchive(const MultiFormatConfig &Config,
98-
const object::Archive &Ar) {
97+
Error objcopy::executeObjcopyOnArchive(const MultiFormatConfig &Config,
98+
const object::Archive &Ar) {
9999
Expected<std::vector<NewArchiveMember>> NewArchiveMembersOrErr =
100100
createNewArchiveMembers(Config, Ar);
101101
if (!NewArchiveMembersOrErr)
@@ -107,6 +107,3 @@ Error executeObjcopyOnArchive(const MultiFormatConfig &Config,
107107
Ar.kind(), CommonConfig.DeterministicArchives,
108108
Ar.isThin());
109109
}
110-
111-
} // end namespace objcopy
112-
} // end namespace llvm

0 commit comments

Comments
 (0)