Skip to content

Commit cfef6ca

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents 71bd694 + 4afeea5 commit cfef6ca

File tree

273 files changed

+1093
-889
lines changed

Some content is hidden

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

273 files changed

+1093
-889
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,8 +5145,10 @@ class OffloadingActionBuilder final {
51455145

51465146
if (A->getOption().matches(options::OPT_fsycl_targets_EQ)) {
51475147
// spir64 target is actually JIT compilation, so we defer selection of
5148-
// bfloat16 libraries to runtime. For AOT we need libraries.
5149-
needLibs = TC->getTriple().getSubArch() != llvm::Triple::NoSubArch;
5148+
// bfloat16 libraries to runtime. For AOT we need libraries, but skip
5149+
// for Nvidia.
5150+
needLibs = TC->getTriple().getSubArch() != llvm::Triple::NoSubArch &&
5151+
!TC->getTriple().isNVPTX();
51505152
TargetBE = GetTripleIt(A->getValue(0));
51515153
if (TargetBE)
51525154
TargetOpt = A->getValue(0);
@@ -5208,9 +5210,9 @@ class OffloadingActionBuilder final {
52085210
// Currently, all SYCL device libraries will be linked by default. Linkage
52095211
// of "internal" libraries cannot be affected via -fno-sycl-device-lib.
52105212
llvm::StringMap<bool> devicelib_link_info = {
5211-
{"libc", true}, {"libm-fp32", true}, {"libm-fp64", true},
5212-
{"libimf-fp32", true}, {"libimf-fp64", true}, {"libimf-bf16", true},
5213-
{"internal", true}};
5213+
{"libc", true}, {"libm-fp32", true}, {"libm-fp64", true},
5214+
{"libimf-fp32", true}, {"libimf-fp64", true}, {"libimf-bf16", true},
5215+
{"libm-bfloat16", true}, {"internal", true}};
52145216
if (Arg *A = Args.getLastArg(options::OPT_fsycl_device_lib_EQ,
52155217
options::OPT_fno_sycl_device_lib_EQ)) {
52165218
if (A->getValues().size() == 0)

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 18 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -991,42 +991,6 @@ static QualType GetSYCLKernelObjectType(const FunctionDecl *KernelCaller) {
991991
return KernelParamTy.getUnqualifiedType();
992992
}
993993

994-
// Get the call operator function associated with the function object
995-
// for both templated and non-templated operator()().
996-
997-
static CXXMethodDecl *getFunctorCallOperator(const CXXRecordDecl *RD) {
998-
DeclarationName Name =
999-
RD->getASTContext().DeclarationNames.getCXXOperatorName(OO_Call);
1000-
DeclContext::lookup_result Calls = RD->lookup(Name);
1001-
1002-
if (Calls.empty())
1003-
return nullptr;
1004-
1005-
NamedDecl *CallOp = Calls.front();
1006-
1007-
if (CallOp == nullptr)
1008-
return nullptr;
1009-
1010-
if (const auto *CallOpTmpl = dyn_cast<FunctionTemplateDecl>(CallOp))
1011-
return cast<CXXMethodDecl>(CallOpTmpl->getTemplatedDecl());
1012-
1013-
return cast<CXXMethodDecl>(CallOp);
1014-
}
1015-
1016-
// Fetch the associated call operator of the kernel object
1017-
// (of either the lambda or the function object).
1018-
static CXXMethodDecl *
1019-
GetCallOperatorOfKernelObject(const CXXRecordDecl *KernelObjType) {
1020-
CXXMethodDecl *CallOperator = nullptr;
1021-
if (!KernelObjType)
1022-
return CallOperator;
1023-
if (KernelObjType->isLambda())
1024-
CallOperator = KernelObjType->getLambdaCallOperator();
1025-
else
1026-
CallOperator = getFunctorCallOperator(KernelObjType);
1027-
return CallOperator;
1028-
}
1029-
1030994
/// Creates a kernel parameter descriptor
1031995
/// \param Src field declaration to construct name from
1032996
/// \param Ty the desired parameter type
@@ -2815,8 +2779,16 @@ class SyclOptReportCreator : public SyclKernelFieldHandler {
28152779
}
28162780
};
28172781

2782+
static CXXMethodDecl *getOperatorParens(const CXXRecordDecl *Rec) {
2783+
for (auto *MD : Rec->methods()) {
2784+
if (MD->getOverloadedOperator() == OO_Call)
2785+
return MD;
2786+
}
2787+
return nullptr;
2788+
}
2789+
28182790
static bool isESIMDKernelType(const CXXRecordDecl *KernelObjType) {
2819-
const CXXMethodDecl *OpParens = getFunctorCallOperator(KernelObjType);
2791+
const CXXMethodDecl *OpParens = getOperatorParens(KernelObjType);
28202792
return (OpParens != nullptr) && OpParens->hasAttr<SYCLSimdAttr>();
28212793
}
28222794

@@ -2903,10 +2875,13 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
29032875

29042876
// Fetch the kernel object and the associated call operator
29052877
// (of either the lambda or the function object).
2906-
const CXXRecordDecl *KernelObj =
2878+
CXXRecordDecl *KernelObj =
29072879
GetSYCLKernelObjectType(KernelCallerFunc)->getAsCXXRecordDecl();
2908-
CXXMethodDecl *WGLambdaFn = GetCallOperatorOfKernelObject(KernelObj);
2909-
2880+
CXXMethodDecl *WGLambdaFn = nullptr;
2881+
if (KernelObj->isLambda())
2882+
WGLambdaFn = KernelObj->getLambdaCallOperator();
2883+
else
2884+
WGLambdaFn = getOperatorParens(KernelObj);
29102885
assert(WGLambdaFn && "non callable object is passed as kernel obj");
29112886
// Mark the function that it "works" in a work group scope:
29122887
// NOTE: In case of parallel_for_work_item the marker call itself is
@@ -3563,7 +3538,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
35633538
static bool IsSYCLUnnamedKernel(Sema &SemaRef, const FunctionDecl *FD) {
35643539
if (!SemaRef.getLangOpts().SYCLUnnamedLambda)
35653540
return false;
3566-
const QualType FunctorTy = GetSYCLKernelObjectType(FD);
3541+
QualType FunctorTy = GetSYCLKernelObjectType(FD);
35673542
QualType TmplArgTy = calculateKernelNameType(SemaRef.Context, FD);
35683543
return SemaRef.Context.hasSameType(FunctorTy, TmplArgTy);
35693544
}
@@ -3989,7 +3964,7 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc,
39893964
const CXXRecordDecl *KernelObj =
39903965
GetSYCLKernelObjectType(KernelFunc)->getAsCXXRecordDecl();
39913966

3992-
if (!GetCallOperatorOfKernelObject(KernelObj)) {
3967+
if (!KernelObj) {
39933968
Diag(Args[0]->getExprLoc(), diag::err_sycl_kernel_not_function_object);
39943969
KernelFunc->setInvalidDecl();
39953970
return;
@@ -4055,7 +4030,7 @@ void Sema::CheckSYCLKernelCall(FunctionDecl *KernelFunc,
40554030
// kernel to wrapped kernel.
40564031
void Sema::copySYCLKernelAttrs(const CXXRecordDecl *KernelObj) {
40574032
// Get the operator() function of the wrapper.
4058-
CXXMethodDecl *OpParens = getFunctorCallOperator(KernelObj);
4033+
CXXMethodDecl *OpParens = getOperatorParens(KernelObj);
40594034
assert(OpParens && "invalid kernel object");
40604035

40614036
typedef std::pair<FunctionDecl *, FunctionDecl *> ChildParentPair;

clang/test/CodeGenCUDASPIRV/copy-aggregate-byval.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv32 \
55
// RUN: -nocudalib -nocudainc %s -o %t.bc -c 2>&1
6-
// RUN: llvm-dis %t.bc -o %t.ll
6+
// RUN: llvm-dis -opaque-pointers %t.bc -o %t.ll
77
// RUN: FileCheck %s --input-file=%t.ll
88

99
// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv64 \
1010
// RUN: -nocudalib -nocudainc %s -o %t.bc -c 2>&1
11-
// RUN: llvm-dis %t.bc -o %t.ll
11+
// RUN: llvm-dis -opaque-pointers %t.bc -o %t.ll
1212
// RUN: FileCheck %s --input-file=%t.ll
1313

1414
class GpuData {

clang/test/CodeGenCUDASPIRV/kernel-argument.cu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv32 \
55
// RUN: -nocudalib -nocudainc %s -o %t.bc -c 2>&1
6-
// RUN: llvm-dis %t.bc -o %t.ll
6+
// RUN: llvm-dis -opaque-pointers %t.bc -o %t.ll
77
// RUN: FileCheck %s --input-file=%t.ll
88

99
// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv64 \
1010
// RUN: -nocudalib -nocudainc %s -o %t.bc -c 2>&1
11-
// RUN: llvm-dis %t.bc -o %t.ll
11+
// RUN: llvm-dis -opaque-pointers %t.bc -o %t.ll
1212
// RUN: FileCheck %s --input-file=%t.ll
1313

1414
// CHECK: define

clang/test/Driver/Inputs/SYCL/lib/libsycl-fallback-bfloat16.o

Whitespace-only changes.

clang/test/Driver/Inputs/SYCL/lib/libsycl-native-bfloat16.o

Whitespace-only changes.

0 commit comments

Comments
 (0)