Skip to content

Commit b4e34c1

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents dee2ee9 + c62860f commit b4e34c1

36 files changed

+717
-152
lines changed

buildbot/dependency.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
ocl_cpu_rt_ver=2020.11.11.0.04
44
# https://github.com/intel/llvm/releases/download/2020-WW45/win-oclcpuexp-2020.11.11.0.04_rel.zip
55
ocl_cpu_rt_ver_win=2020.11.11.0.04
6-
# Same GPU driver supports Level Zero and OpenCL:
7-
# https://github.com/intel/compute-runtime/releases/tag/20.45.18403
8-
ocl_gpu_rt_ver=20.45.18403
9-
# Same GPU driver supports Level Zero and OpenCL:
6+
# Same GPU driver supports Level Zero and OpenCL
7+
# https://github.com/intel/compute-runtime/releases/tag/20.46.18421
8+
ocl_gpu_rt_ver=20.46.18421
9+
# Same GPU driver supports Level Zero and OpenCL
1010
# https://downloadmirror.intel.com/29988/a08/igfx_win10_100.8935.zip
1111
ocl_gpu_rt_ver_win=27.20.100.8935
1212
intel_sycl_ver=build
@@ -25,7 +25,7 @@ fpga_ver_win=20201022_000005
2525
[DRIVER VERSIONS]
2626
cpu_driver_lin=2020.11.11.0.04
2727
cpu_driver_win=2020.11.11.0.04
28-
gpu_driver_lin=20.45.18403
28+
gpu_driver_lin=20.46.18421
2929
gpu_driver_win=27.20.100.8935
3030
fpga_driver_lin=2020.11.11.0.04
3131
fpga_driver_win=2020.11.11.0.04

clang/include/clang/AST/Type.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ class Qualifiers {
384384
| (((uint32_t) space) << AddressSpaceShift);
385385
}
386386
void removeAddressSpace() { setAddressSpace(LangAS::Default); }
387-
void addAddressSpace(LangAS space) {
388-
assert(space != LangAS::Default);
387+
void addAddressSpace(LangAS space, bool AllowDefaultAddrSpace = false) {
388+
assert(space != LangAS::Default || AllowDefaultAddrSpace);
389389
setAddressSpace(space);
390390
}
391391

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,7 +2791,7 @@ bool Driver::checkForOffloadStaticLib(Compilation &C,
27912791
if (Args.hasArg(options::OPT_offload_lib_Group))
27922792
return true;
27932793
SmallVector<const char *, 16> OffloadLibArgs(getLinkerArgs(C, Args));
2794-
for (const StringRef &OLArg : OffloadLibArgs)
2794+
for (StringRef OLArg : OffloadLibArgs)
27952795
if (isStaticArchiveFile(OLArg) && hasOffloadSections(C, OLArg, Args)) {
27962796
// FPGA binaries with AOCX or AOCR sections are not considered fat
27972797
// static archives.
@@ -4443,7 +4443,7 @@ class OffloadingActionBuilder final {
44434443
// incorporated into the aoc compilation
44444444
if (SYCLfpgaTriple) {
44454445
SmallVector<const char *, 16> LinkArgs(getLinkerArgs(C, Args));
4446-
for (const StringRef &LA : LinkArgs) {
4446+
for (StringRef LA : LinkArgs) {
44474447
if (isStaticArchiveFile(LA) && hasOffloadSections(C, LA, Args)) {
44484448
const llvm::opt::OptTable &Opts = C.getDriver().getOpts();
44494449
Arg *InputArg = MakeInputArg(Args, Opts, Args.MakeArgString(LA));
@@ -5124,7 +5124,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
51245124
UnbundlerInputs.push_back(Current);
51255125
};
51265126
bool IsWholeArchive = false;
5127-
for (const StringRef &LA : LinkArgs) {
5127+
for (StringRef LA : LinkArgs) {
51285128
if (isStaticArchiveFile(LA)) {
51295129
addUnbundlerInput(
51305130
IsWholeArchive ? types::TY_WholeArchive : types::TY_Archive, LA);

clang/lib/Sema/SemaInit.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4905,7 +4905,8 @@ static void TryReferenceInitializationCore(Sema &S,
49054905
// Add addr space conversion if required.
49064906
if (T1Quals.getAddressSpace() != T2Quals.getAddressSpace()) {
49074907
auto T4Quals = cv1T4.getQualifiers();
4908-
T4Quals.addAddressSpace(T1Quals.getAddressSpace());
4908+
T4Quals.addAddressSpace(T1Quals.getAddressSpace(),
4909+
S.getLangOpts().SYCLIsDevice);
49094910
QualType cv1T4WithAS = S.Context.getQualifiedType(T2, T4Quals);
49104911
Sequence.AddQualificationConversionStep(cv1T4WithAS, ValueKind);
49114912
cv1T4 = cv1T4WithAS;

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ class KernelObjVisitor {
816816
template <typename... Tn>
817817
bool handleField(FieldDecl *FD, QualType FDTy, Tn &&... tn) {
818818
bool result = true;
819-
std::initializer_list<int>{(result = result && tn(FD, FDTy), 0)...};
819+
(void)std::initializer_list<int>{(result = result && tn(FD, FDTy), 0)...};
820820
return result;
821821
}
822822
template <typename... Tn>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// REQUIRES: x86-registered-target
2+
3+
// This test check that clang-offload-bundler adds .tgtsym section to the output
4+
// file when creating a fat object. This section contains names of the external
5+
// symbols defined in the embdedded target objects with target prefixes.
6+
7+
// RUN: %clang -target %itanium_abi_triple -c %s -o %t.o
8+
// RUN: %clang -target x86_64-pc-linux-gnu -c %s -o %t.tgt1
9+
// RUN: %clang -target spir64 -emit-llvm -c %s -o %t.tgt2
10+
11+
// RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu,sycl-spir64 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.fat.o
12+
// RUN: llvm-readobj --string-dump=.tgtsym %t.fat.o | FileCheck %s
13+
14+
// CHECK: String dump of section '.tgtsym':
15+
// CHECK-DAG: openmp-x86_64-pc-linux-gnu.foo
16+
// CHECK-DAG: openmp-x86_64-pc-linux-gnu.bar
17+
// CHECK-DAG: sycl-spir64.foo
18+
// CHECK-DAG: sycl-spir64.bar
19+
// CHECK-NOT: undefined_func
20+
// CHECK-NOT: static_func
21+
22+
extern void undefined_func(void);
23+
24+
void foo(void) {
25+
undefined_func();
26+
}
27+
28+
static void static_func(void) __attribute__((noinline));
29+
static void static_func(void) {}
30+
31+
void bar(void) {
32+
static_func();
33+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify %s
2+
3+
// Test that the compiler no longer asserts while processing this test case.
4+
5+
template <int N>
6+
struct integral_constant {
7+
static constexpr int val = N;
8+
};
9+
template <typename T>
10+
T &&convert(int);
11+
template <typename T>
12+
auto declval(convert<T>(0));
13+
template <typename Op1, typename Op2>
14+
class sub_group {
15+
template <typename T, decltype(declval<T>)>
16+
// expected-note@+1 {{possible target for call}}
17+
static integral_constant<true> binary_op();
18+
// expected-error@+1 {{reference to overloaded function could not be resolved; did you mean to call it?}}
19+
decltype(binary_op<Op1, Op2>) i;
20+
};
21+
// expected-note-re@+2 {{in instantiation {{.*}} requested here}}
22+
template <typename n>
23+
struct group : sub_group<n, int> {
24+
};
25+
template <typename T>
26+
struct wrapper {
27+
typedef T val;
28+
};
29+
class element_type {
30+
};
31+
struct Container {
32+
using __element_type = __attribute__((opencl_global)) element_type;
33+
};
34+
template <bool, class Base, class> using BaseImpl = Base;
35+
// expected-note-re@+1 2{{candidate constructor {{.*}} not viable: {{.*}}}}
36+
template <int> class id_type {
37+
template <class...> struct Base;
38+
// expected-note-re@+1 {{in instantiation {{.*}} requested here}}
39+
template <class Der> struct Base<Der> : BaseImpl<Der::val, Base<>, Der> {};
40+
// expected-note-re@+1 {{in instantiation {{.*}} requested here}}
41+
template <typename T> using Base2 = wrapper<typename Base<group<T>>::val>;
42+
// expected-note-re@+3 {{in instantiation {{.*}} requested here}}
43+
// expected-note-re@+2 {{in instantiation {{.*}} required here}}
44+
// expected-note-re@+1 {{candidate template ignored: {{.*}}}}
45+
template <typename T, typename = Base2<T>> id_type(T &);
46+
};
47+
id_type<1> get() {
48+
Container::__element_type *ElemPtr;
49+
// expected-error@+2 {{no viable conversion from returned value of type 'Container::__element_type' (aka '__global element_type') to function return type 'id_type<1>'}}
50+
// expected-note-re@+1 {{while substituting {{.*}}}}
51+
return ElemPtr[0];
52+
}

clang/tools/clang-offload-bundler/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set(LLVM_LINK_COMPONENTS Object Support)
1+
set(LLVM_LINK_COMPONENTS Core Object Support)
22

33
add_clang_tool(clang-offload-bundler
44
ClangOffloadBundler.cpp

clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "llvm/ADT/StringSet.h"
2424
#include "llvm/ADT/StringSwitch.h"
2525
#include "llvm/ADT/Triple.h"
26+
#include "llvm/IR/LLVMContext.h"
2627
#include "llvm/Object/Archive.h"
2728
#include "llvm/Object/ArchiveWriter.h"
2829
#include "llvm/Object/Binary.h"
@@ -121,6 +122,9 @@ static cl::opt<unsigned>
121122
/// Prefix of an added section name with bundle size.
122123
#define SIZE_SECTION_PREFIX "__CLANG_OFFLOAD_BUNDLE_SIZE__"
123124

125+
/// Section name which holds target symbol names.
126+
#define SYMBOLS_SECTION_NAME ".tgtsym"
127+
124128
/// The index of the host input in the list of inputs.
125129
static unsigned HostInputIndex = ~0u;
126130

@@ -546,6 +550,62 @@ class ObjectFileHandler final : public FileHandler {
546550
/// Input sizes.
547551
SmallVector<uint64_t, 16u> InputSizes;
548552

553+
// Return a buffer with symbol names that are defined in target objects.
554+
// Each symbol name is prefixed by a target name <kind>-<triple> to uniquely
555+
// identify the target it belongs to, and symbol names are separated from each
556+
// other by '\0' characters.
557+
Expected<SmallVector<char, 0>> makeTargetSymbolTable() {
558+
SmallVector<char, 0> SymbolsBuf;
559+
raw_svector_ostream SymbolsOS(SymbolsBuf);
560+
561+
for (unsigned I = 0; I < NumberOfInputs; ++I) {
562+
if (I == HostInputIndex)
563+
continue;
564+
565+
// Get the list of symbols defined in the target object. Open file and
566+
// check if it is a symbolic file.
567+
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
568+
MemoryBuffer::getFileOrSTDIN(InputFileNames[I]);
569+
if (!BufOrErr)
570+
return createFileError(InputFileNames[I], BufOrErr.getError());
571+
572+
LLVMContext Context;
573+
Expected<std::unique_ptr<Binary>> BinOrErr =
574+
createBinary(BufOrErr.get()->getMemBufferRef(), &Context);
575+
576+
// If it is not a symbolic file just ignore it since we cannot do anything
577+
// with it.
578+
if (!BinOrErr) {
579+
if (auto Err = isNotObjectErrorInvalidFileType(BinOrErr.takeError()))
580+
return std::move(Err);
581+
continue;
582+
}
583+
auto *SF = dyn_cast<SymbolicFile>(&**BinOrErr);
584+
if (!SF)
585+
continue;
586+
587+
for (BasicSymbolRef Symbol : SF->symbols()) {
588+
Expected<uint32_t> FlagsOrErr = Symbol.getFlags();
589+
if (!FlagsOrErr)
590+
return FlagsOrErr.takeError();
591+
592+
// We are interested in externally visible and defined symbols only, so
593+
// ignore it if this is not such a symbol.
594+
bool Undefined = *FlagsOrErr & SymbolRef::SF_Undefined;
595+
bool Global = *FlagsOrErr & SymbolRef::SF_Global;
596+
if (Undefined || !Global)
597+
continue;
598+
599+
// Add symbol name with the target prefix to the buffer.
600+
SymbolsOS << TargetNames[I] << ".";
601+
if (Error Err = Symbol.printName(SymbolsOS))
602+
return std::move(Err);
603+
SymbolsOS << '\0';
604+
}
605+
}
606+
return SymbolsBuf;
607+
}
608+
549609
public:
550610
ObjectFileHandler(std::unique_ptr<ObjectFile> ObjIn)
551611
: FileHandler(), Obj(std::move(ObjIn)),
@@ -793,6 +853,25 @@ class ObjectFileHandler final : public FileHandler {
793853
SIZE_SECTION_PREFIX + TargetNames[I] + "=" +
794854
*SizeFileOrErr));
795855
}
856+
857+
// Add a section with symbol names that are defined in target objects to the
858+
// output fat object.
859+
Expected<SmallVector<char, 0>> SymbolsOrErr = makeTargetSymbolTable();
860+
if (!SymbolsOrErr)
861+
return SymbolsOrErr.takeError();
862+
863+
if (!SymbolsOrErr->empty()) {
864+
// Add section with symbols names to fat object.
865+
Expected<StringRef> SymbolsFileOrErr =
866+
TempFiles.Create(makeArrayRef(*SymbolsOrErr));
867+
if (!SymbolsFileOrErr)
868+
return SymbolsFileOrErr.takeError();
869+
870+
ObjcopyArgs.push_back(SS.save(Twine("--add-section=") +
871+
SYMBOLS_SECTION_NAME + "=" +
872+
*SymbolsFileOrErr));
873+
}
874+
796875
ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
797876
ObjcopyArgs.push_back(IntermediateObj);
798877

llvm/lib/Support/PropertySetIO.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ PropertyValue &PropertyValue::operator=(PropertyValue &&P) {
182182

183183
PropertyValue &PropertyValue::operator=(const PropertyValue &P) {
184184
if (P.getType() == BYTE_ARRAY)
185-
*this =
186-
std::move(PropertyValue(P.asByteArray(), P.getByteArraySizeInBits()));
185+
*this = PropertyValue(P.asByteArray(), P.getByteArraySizeInBits());
187186
else
188187
copy(P);
189188
return *this;

llvm/lib/Support/SimpleTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Error SimpleTable::addColumn(const Twine &Title, ArrayRef<std::string> Cells) {
7676
if (!Rows.empty() && (Rows.size() != N))
7777
return makeError("column size mismatch for " + Title);
7878
if (Error Err = addColumnName(Title.str()))
79-
return std::move(Err);
79+
return Err;
8080
if (Rows.empty()) {
8181
Rows.resize(Cells.size());
8282
for (auto &R : Rows)
@@ -114,7 +114,7 @@ Error SimpleTable::renameColumn(StringRef OldName, StringRef NewName) {
114114

115115
if (I < 0)
116116
return makeError("column not found: " + OldName);
117-
*ColumnNum2Name[I] = std::move(NewName.str());
117+
*ColumnNum2Name[I] = NewName.str();
118118
ColumnName2Num.erase(OldName);
119119
ColumnName2Num[StringRef(*ColumnNum2Name[I])] = I;
120120
return Error::success();

sycl/include/CL/sycl/ONEAPI/experimental/spec_constant.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#pragma once
1919

20+
#include <CL/sycl/detail/stl_type_traits.hpp>
2021
#include <CL/sycl/detail/sycl_fe_intrins.hpp>
2122
#include <CL/sycl/exception.hpp>
2223

@@ -41,11 +42,15 @@ template <typename T, typename ID = T> class spec_constant {
4142
spec_constant(T Cst) : Val(Cst) {}
4243

4344
T Val;
44-
#endif
45+
#else
46+
char padding[sizeof(T)];
47+
#endif // __SYCL_DEVICE_ONLY__
4548
friend class cl::sycl::program;
4649

4750
public:
48-
T get() const { // explicit access.
51+
template <typename V = T>
52+
typename sycl::detail::enable_if_t<std::is_arithmetic<V>::value, V>
53+
get() const { // explicit access.
4954
#ifdef __SYCL_DEVICE_ONLY__
5055
const char *TName = __builtin_unique_stable_name(ID);
5156
return __sycl_getSpecConstantValue<T>(TName);
@@ -54,6 +59,19 @@ template <typename T, typename ID = T> class spec_constant {
5459
#endif // __SYCL_DEVICE_ONLY__
5560
}
5661

62+
template <typename V = T>
63+
typename sycl::detail::enable_if_t<std::is_class<V>::value &&
64+
std::is_pod<V>::value,
65+
V>
66+
get() const { // explicit access.
67+
#ifdef __SYCL_DEVICE_ONLY__
68+
const char *TName = __builtin_unique_stable_name(ID);
69+
return __sycl_getCompositeSpecConstantValue<T>(TName);
70+
#else
71+
return Val;
72+
#endif // __SYCL_DEVICE_ONLY__
73+
}
74+
5775
operator T() const { // implicit conversion.
5876
return get();
5977
}

0 commit comments

Comments
 (0)