Skip to content

Commit b4e8fee

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web'
2 parents 72c157c + 990e802 commit b4e8fee

File tree

168 files changed

+2646
-2488
lines changed

Some content is hidden

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

168 files changed

+2646
-2488
lines changed

clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp

+16-24
Original file line numberDiff line numberDiff line change
@@ -88,47 +88,39 @@ bool PopulateSwitch::prepare(const Selection &Sel) {
8888
if (!CA)
8989
return false;
9090

91-
const Stmt *CAStmt = CA->ASTNode.get<Stmt>();
92-
if (!CAStmt)
93-
return false;
94-
95-
// Go up a level if we see a compound statement.
96-
// switch (value) {}
97-
// ^^
98-
if (isa<CompoundStmt>(CAStmt)) {
99-
CA = CA->Parent;
100-
if (!CA)
101-
return false;
102-
103-
CAStmt = CA->ASTNode.get<Stmt>();
104-
if (!CAStmt)
91+
// Support targeting
92+
// - the switch statement itself (keyword, parens)
93+
// - the whole expression (possibly wrapped in implicit casts)
94+
// - the outer body (typically CompoundStmt)
95+
// Selections *within* the expression or body don't trigger.
96+
// direct child (the
97+
Switch = CA->ASTNode.get<SwitchStmt>();
98+
if (!Switch) {
99+
if (const SelectionTree::Node *Parent = CA->outerImplicit().Parent)
100+
Switch = Parent->ASTNode.get<SwitchStmt>();
101+
if (!Switch)
105102
return false;
106103
}
107-
108-
DeclCtx = &CA->getDeclContext();
109-
Switch = dyn_cast<SwitchStmt>(CAStmt);
110-
if (!Switch)
111-
return false;
112-
113-
Body = dyn_cast<CompoundStmt>(Switch->getBody());
104+
// Body need not be a CompoundStmt! But that's all we support editing.
105+
Body = llvm::dyn_cast_or_null<CompoundStmt>(Switch->getBody());
114106
if (!Body)
115107
return false;
108+
DeclCtx = &CA->getDeclContext();
116109

110+
// Examine the condition of the switch statement to see if it's an enum.
117111
const Expr *Cond = Switch->getCond();
118112
if (!Cond)
119113
return false;
120-
121114
// Ignore implicit casts, since enums implicitly cast to integer types.
122115
Cond = Cond->IgnoreParenImpCasts();
123-
124116
EnumT = Cond->getType()->getAsAdjusted<EnumType>();
125117
if (!EnumT)
126118
return false;
127-
128119
EnumD = EnumT->getDecl();
129120
if (!EnumD || EnumD->isDependentType())
130121
return false;
131122

123+
// Finally, check which cases exist and which are covered.
132124
// We trigger if there are any values in the enum that aren't covered by the
133125
// switch.
134126

clang-tools-extra/clangd/unittests/tweaks/PopulateSwitchTests.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ TEST_F(PopulateSwitchTest, Test) {
9595
R""(enum Enum {A}; switch (^A) {})"",
9696
R""(enum Enum {A}; switch (A) {case A:break;})"",
9797
},
98+
{
99+
// Selection of whole switch condition
100+
Function,
101+
R""(enum Enum {A}; switch ([[A]]) {})"",
102+
R""(enum Enum {A}; switch (A) {case A:break;})"",
103+
},
98104
{
99105
// Selection in switch body
100106
Function,

clang/lib/CodeGen/CGOpenMPRuntime.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -4401,14 +4401,14 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction &CGF, SourceLocation Loc,
44014401
if (NumOfElements) {
44024402
NumOfElements = CGF.Builder.CreateNUWAdd(
44034403
llvm::ConstantInt::get(CGF.SizeTy, NumAffinities), NumOfElements);
4404-
OpaqueValueExpr OVE(
4404+
auto *OVE = new (C) OpaqueValueExpr(
44054405
Loc,
44064406
C.getIntTypeForBitwidth(C.getTypeSize(C.getSizeType()), /*Signed=*/0),
44074407
VK_PRValue);
4408-
CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, &OVE,
4408+
CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
44094409
RValue::get(NumOfElements));
44104410
KmpTaskAffinityInfoArrayTy =
4411-
C.getVariableArrayType(KmpTaskAffinityInfoTy, &OVE, ArrayType::Normal,
4411+
C.getVariableArrayType(KmpTaskAffinityInfoTy, OVE, ArrayType::Normal,
44124412
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
44134413
// Properly emit variable-sized array.
44144414
auto *PD = ImplicitParamDecl::Create(C, KmpTaskAffinityInfoArrayTy,
@@ -4899,13 +4899,13 @@ std::pair<llvm::Value *, Address> CGOpenMPRuntime::emitDependClause(
48994899
NumOfElements =
49004900
CGF.Builder.CreateNUWAdd(NumOfRegularWithIterators, NumOfElements);
49014901
}
4902-
OpaqueValueExpr OVE(Loc,
4903-
C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
4904-
VK_PRValue);
4905-
CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, &OVE,
4902+
auto *OVE = new (C) OpaqueValueExpr(
4903+
Loc, C.getIntTypeForBitwidth(/*DestWidth=*/64, /*Signed=*/0),
4904+
VK_PRValue);
4905+
CodeGenFunction::OpaqueValueMapping OpaqueMap(CGF, OVE,
49064906
RValue::get(NumOfElements));
49074907
KmpDependInfoArrayTy =
4908-
C.getVariableArrayType(KmpDependInfoTy, &OVE, ArrayType::Normal,
4908+
C.getVariableArrayType(KmpDependInfoTy, OVE, ArrayType::Normal,
49094909
/*IndexTypeQuals=*/0, SourceRange(Loc, Loc));
49104910
// CGF.EmitVariablyModifiedType(KmpDependInfoArrayTy);
49114911
// Properly emit variable-sized array.

clang/lib/Driver/ToolChains/AVR.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ llvm::Optional<unsigned> GetMCUSectionAddressData(StringRef MCUName) {
298298
}
299299

300300
const StringRef PossibleAVRLibcLocations[] = {
301+
"/avr",
301302
"/usr/avr",
302303
"/usr/lib/avr",
303304
};

clang/lib/Driver/ToolChains/Clang.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5167,7 +5167,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
51675167
if (StringRef(A->getValue()).getAsInteger(10, Value) || Value > 65536)
51685168
TC.getDriver().Diag(diag::err_drv_invalid_int_value)
51695169
<< A->getAsString(Args) << A->getValue();
5170-
else if (Value & Value - 1)
5170+
else if (Value & (Value - 1))
51715171
TC.getDriver().Diag(diag::err_drv_alignment_not_power_of_two)
51725172
<< A->getAsString(Args) << A->getValue();
51735173
// Treat =0 as unspecified (use the target preference).

clang/lib/Headers/opencl-c-base.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,13 @@ typedef enum memory_scope {
333333
memory_scope_all_devices = memory_scope_all_svm_devices,
334334
#endif // __OPENCL_C_VERSION__ >= CL_VERSION_3_0
335335
#endif // defined(__opencl_c_atomic_scope_all_devices)
336-
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
336+
/**
337+
* Subgroups have different requirements on forward progress, so just test
338+
* all the relevant macros.
339+
* CL 3.0 sub-groups "they are not guaranteed to make independent forward progress"
340+
* KHR subgroups "Subgroups within a workgroup are independent, make forward progress with respect to each other"
341+
*/
342+
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups)
337343
memory_scope_sub_group = __OPENCL_MEMORY_SCOPE_SUB_GROUP
338344
#endif
339345
} memory_scope;

clang/lib/Headers/opencl-c.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -16011,7 +16011,7 @@ int __ovld get_image_num_samples(read_write image2d_array_msaa_depth_t image);
1601116011

1601216012
// OpenCL v2.0 s6.13.15 - Work-group Functions
1601316013

16014-
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
16014+
#if defined(__opencl_c_work_group_collective_functions)
1601516015
int __ovld __conv work_group_all(int predicate);
1601616016
int __ovld __conv work_group_any(int predicate);
1601716017

@@ -16109,12 +16109,12 @@ double __ovld __conv work_group_scan_inclusive_min(double x);
1610916109
double __ovld __conv work_group_scan_inclusive_max(double x);
1611016110
#endif //cl_khr_fp64
1611116111

16112-
#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
16112+
#endif //defined(__opencl_c_work_group_collective_functions)
1611316113

1611416114
// OpenCL v2.0 s6.13.16 - Pipe Functions
16115-
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
16115+
#if defined(__opencl_c_pipes)
1611616116
bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);
16117-
#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
16117+
#endif //defined(__opencl_c_pipes)
1611816118

1611916119

1612016120
// OpenCL v2.0 s6.13.17 - Enqueue Kernels
@@ -16151,7 +16151,7 @@ queue_t __ovld get_default_queue(void);
1615116151

1615216152
// OpenCL Extension v2.0 s9.17 - Sub-groups
1615316153

16154-
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups)
16154+
#if defined(cl_intel_subgroups) || defined(cl_khr_subgroups) || defined(__opencl_c_subgroups)
1615516155
// Shared Sub Group Functions
1615616156
uint __ovld get_sub_group_size(void);
1615716157
uint __ovld get_max_sub_group_size(void);
@@ -16250,7 +16250,7 @@ double __ovld __conv sub_group_scan_inclusive_min(double x);
1625016250
double __ovld __conv sub_group_scan_inclusive_max(double x);
1625116251
#endif //cl_khr_fp64
1625216252

16253-
#endif //cl_khr_subgroups cl_intel_subgroups
16253+
#endif //cl_khr_subgroups cl_intel_subgroups __opencl_c_subgroups
1625416254

1625516255
#if defined(cl_khr_subgroup_extended_types)
1625616256
char __ovld __conv sub_group_broadcast( char value, uint index );
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu \
2+
// RUN: -emit-llvm %s -o - | FileCheck %s
3+
4+
// expected-no-diagnostics
5+
6+
extern int bounds1(int);
7+
extern int bounds2(int);
8+
9+
extern void fun2(int n, int *a, int *b);
10+
extern void fun3(int n, int *a, int *b);
11+
12+
void fun1(int n, int *a, int *b)
13+
{
14+
#pragma omp task depend(iterator(j = 0 : bounds1(n)), in : a[b[j]])
15+
{
16+
fun2(n, a, b);
17+
}
18+
// CHECK: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA:%.*]], align 16
19+
20+
#pragma omp task depend(iterator(j = 0 : bounds2(n)), in : a[b[j]])
21+
{
22+
fun3(n, a, b);
23+
}
24+
// CHECK-NOT: alloca %struct.kmp_depend_info, i64 [[FIRST_VLA]], align 16
25+
}

clang/tools/libclang/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ if(ENABLE_SHARED)
162162
endif()
163163
if (USE_VERSION_SCRIPT)
164164
target_link_options(libclang PRIVATE "-Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/libclang.map")
165+
# The Solaris 11.4 linker supports a subset of GNU ld version scripts,
166+
# but requires a special option to enable it.
167+
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
168+
target_link_options(libclang PRIVATE "-Wl,-z,gnu-version-script-compat")
169+
endif()
165170
# Ensure that libclang.so gets rebuilt when the linker script changes.
166171
set_property(SOURCE ARCMigrate.cpp APPEND PROPERTY
167172
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libclang.map)

clang/tools/libclang/libclang.map

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
/* If you add a symbol to this file, make sure to add it with the correct
2-
* version. For example, if the LLVM main branch is LLVM 14.0.0, add new
3-
* symbols with the version LLVM_14.
4-
* On platforms where versions scripts are not used, this file will be used to
5-
* generate a list of exports for libclang.so
6-
*/
7-
1+
# If you add a symbol to this file, make sure to add it with the correct
2+
# version. For example, if the LLVM main branch is LLVM 14.0.0, add new
3+
# symbols with the version LLVM_14.
4+
# On platforms where versions scripts are not used, this file will be used to
5+
# generate a list of exports for libclang.so
86

97
LLVM_13 {
108
global:
@@ -407,10 +405,9 @@ LLVM_13 {
407405
local: *;
408406
};
409407

410-
/* Example of how to add a new symbol version entry. If you do add a new symbol
411-
* version, please update the example to depend on the version you added.
412-
* LLVM_X {
413-
* global:
414-
* clang_newsymbol;
415-
* };
416-
*/
408+
# Example of how to add a new symbol version entry. If you do add a new symbol
409+
# version, please update the example to depend on the version you added.
410+
# LLVM_X {
411+
# global:
412+
# clang_newsymbol;
413+
# };

compiler-rt/lib/profile/InstrProfilingUtil.c

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#endif
3535

3636
#if defined(__Fuchsia__)
37+
#include <zircon/process.h>
3738
#include <zircon/syscalls.h>
3839
#endif
3940

lld/ELF/InputSection.cpp

+20-27
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,22 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
8888
if (!zlib::isAvailable())
8989
error(toString(file) + ": contains a compressed section, " +
9090
"but zlib is not available");
91-
parseCompressedHeader();
91+
switch (config->ekind) {
92+
case ELF32LEKind:
93+
parseCompressedHeader<ELF32LE>();
94+
break;
95+
case ELF32BEKind:
96+
parseCompressedHeader<ELF32BE>();
97+
break;
98+
case ELF64LEKind:
99+
parseCompressedHeader<ELF64LE>();
100+
break;
101+
case ELF64BEKind:
102+
parseCompressedHeader<ELF64BE>();
103+
break;
104+
default:
105+
llvm_unreachable("unknown ELFT");
106+
}
92107
}
93108
}
94109

@@ -210,10 +225,7 @@ OutputSection *SectionBase::getOutputSection() {
210225
// When a section is compressed, `rawData` consists with a header followed
211226
// by zlib-compressed data. This function parses a header to initialize
212227
// `uncompressedSize` member and remove the header from `rawData`.
213-
void InputSectionBase::parseCompressedHeader() {
214-
using Chdr64 = typename ELF64LE::Chdr;
215-
using Chdr32 = typename ELF32LE::Chdr;
216-
228+
template <typename ELFT> void InputSectionBase::parseCompressedHeader() {
217229
// Old-style header
218230
if (name.startswith(".zdebug")) {
219231
if (!toStringRef(rawData).startswith("ZLIB")) {
@@ -239,32 +251,13 @@ void InputSectionBase::parseCompressedHeader() {
239251
assert(flags & SHF_COMPRESSED);
240252
flags &= ~(uint64_t)SHF_COMPRESSED;
241253

242-
// New-style 64-bit header
243-
if (config->is64) {
244-
if (rawData.size() < sizeof(Chdr64)) {
245-
error(toString(this) + ": corrupted compressed section");
246-
return;
247-
}
248-
249-
auto *hdr = reinterpret_cast<const Chdr64 *>(rawData.data());
250-
if (hdr->ch_type != ELFCOMPRESS_ZLIB) {
251-
error(toString(this) + ": unsupported compression type");
252-
return;
253-
}
254-
255-
uncompressedSize = hdr->ch_size;
256-
alignment = std::max<uint32_t>(hdr->ch_addralign, 1);
257-
rawData = rawData.slice(sizeof(*hdr));
258-
return;
259-
}
260-
261-
// New-style 32-bit header
262-
if (rawData.size() < sizeof(Chdr32)) {
254+
// New-style header
255+
if (rawData.size() < sizeof(typename ELFT::Chdr)) {
263256
error(toString(this) + ": corrupted compressed section");
264257
return;
265258
}
266259

267-
auto *hdr = reinterpret_cast<const Chdr32 *>(rawData.data());
260+
auto *hdr = reinterpret_cast<const typename ELFT::Chdr *>(rawData.data());
268261
if (hdr->ch_type != ELFCOMPRESS_ZLIB) {
269262
error(toString(this) + ": unsupported compression type");
270263
return;

lld/ELF/InputSection.h

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class InputSectionBase : public SectionBase {
238238
}
239239

240240
protected:
241+
template <typename ELFT>
241242
void parseCompressedHeader();
242243
void uncompress() const;
243244

lld/test/ELF/compressed-debug-input-err.s

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# REQUIRES: zlib, x86
1+
# REQUIRES: zlib, ppc, x86
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
44
# RUN: not ld.lld %t.o -o /dev/null -shared 2>&1 | FileCheck %s
55

6+
# RUN: llvm-mc -filetype=obj -triple=powerpc64-unknown-unknown %s -o %t-be.o
7+
# RUN: not ld.lld %t-be.o -o /dev/null -shared 2>&1 | FileCheck %s
8+
69
## Check we are able to report zlib uncompress errors.
710
# CHECK: error: {{.*}}.o:(.debug_str): uncompress failed: zlib error: Z_DATA_ERROR
811

lld/test/ELF/compressed-debug-input.s

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# REQUIRES: zlib, x86
1+
# REQUIRES: zlib, ppc, x86
22

33
# RUN: llvm-mc -compress-debug-sections=zlib -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4+
# RUN: llvm-mc -compress-debug-sections=zlib -filetype=obj -triple=powerpc64-unknown-unknown %s -o %t-be
45
# RUN: llvm-readobj --sections %t | FileCheck -check-prefix=ZLIB %s
6+
# RUN: llvm-readobj --sections %t-be | FileCheck -check-prefix=ZLIB %s
57
# ZLIB: Section {
68
# ZLIB: Index: 2
79
# ZLIB: Name: .debug_str
@@ -21,7 +23,9 @@
2123
# ZLIB-NEXT: }
2224

2325
# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=x86_64-unknown-linux %s -o %t2
26+
# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=powerpc64-unknown-unknown %s -o %t2-be
2427
# RUN: llvm-readobj --sections %t2 | FileCheck -check-prefix=GNU %s
28+
# RUN: llvm-readobj --sections %t2-be | FileCheck -check-prefix=GNU %s
2529
# GNU: Section {
2630
# GNU: Index: 2
2731
# GNU: Name: .zdebug_str
@@ -41,9 +45,13 @@
4145

4246
# RUN: ld.lld --hash-style=sysv %t -o %t.so -shared
4347
# RUN: llvm-readobj --sections --section-data %t.so | FileCheck -check-prefix=DATA %s
48+
# RUN: ld.lld --hash-style=sysv %t-be -o %t-be.so -shared
49+
# RUN: llvm-readobj --sections --section-data %t-be.so | FileCheck -check-prefix=DATA %s
4450

4551
# RUN: ld.lld --hash-style=sysv %t2 -o %t2.so -shared
4652
# RUN: llvm-readobj --sections --section-data %t2.so | FileCheck -check-prefix=DATA %s
53+
# RUN: ld.lld --hash-style=sysv %t2-be -o %t2-be.so -shared
54+
# RUN: llvm-readobj --sections --section-data %t2-be.so | FileCheck -check-prefix=DATA %s
4755

4856
# DATA: Section {
4957
# DATA: Index: 6

0 commit comments

Comments
 (0)