Skip to content

Commit bda527d

Browse files
author
Erich Keane
committed
Add more const, mess with sycl-simd in switch
1 parent 99747fd commit bda527d

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class DiagDeviceFunction : public RecursiveASTVisitor<DiagDeviceFunction> {
357357
// diagnostics.
358358
unsigned ConstexprDepth = 0;
359359
Sema &SemaRef;
360-
const llvm::SmallPtrSetImpl<FunctionDecl *> &RecursiveFuncs;
360+
const llvm::SmallPtrSetImpl<const FunctionDecl *> &RecursiveFuncs;
361361

362362
struct ConstexprDepthRAII {
363363
DiagDeviceFunction &DDF;
@@ -376,7 +376,8 @@ class DiagDeviceFunction : public RecursiveASTVisitor<DiagDeviceFunction> {
376376

377377
public:
378378
DiagDeviceFunction(
379-
Sema &S, const llvm::SmallPtrSetImpl<FunctionDecl *> &RecursiveFuncs)
379+
Sema &S,
380+
const llvm::SmallPtrSetImpl<const FunctionDecl *> &RecursiveFuncs)
380381
: RecursiveASTVisitor(), SemaRef(S), RecursiveFuncs(RecursiveFuncs) {}
381382

382383
void CheckBody(Stmt *ToBeDiagnosed) { TraverseStmt(ToBeDiagnosed); }
@@ -498,7 +499,7 @@ class DeviceFunctionTracker {
498499
// The list of functions used on the device, kept so we can diagnose on them
499500
// later.
500501
llvm::SmallPtrSet<FunctionDecl *, 16> DeviceFunctions;
501-
llvm::SmallPtrSet<FunctionDecl *, 16> RecursiveFunctions;
502+
llvm::SmallPtrSet<const FunctionDecl *, 16> RecursiveFunctions;
502503

503504
void CollectSyclExternalFuncs() {
504505
for (CallGraphNode::CallRecord Record : CG.getRoot()->callees())
@@ -512,9 +513,9 @@ class DeviceFunctionTracker {
512513
return CG.getNode(Kernel);
513514
}
514515

515-
void
516-
AddSingleFunction(const llvm::SmallPtrSetImpl<FunctionDecl *> &DevFuncs,
517-
const llvm::SmallPtrSetImpl<FunctionDecl *> &Recursive) {
516+
void AddSingleFunction(
517+
const llvm::SmallPtrSetImpl<FunctionDecl *> &DevFuncs,
518+
const llvm::SmallPtrSetImpl<const FunctionDecl *> &Recursive) {
518519
DeviceFunctions.insert(DevFuncs.begin(), DevFuncs.end());
519520
RecursiveFunctions.insert(Recursive.begin(), Recursive.end());
520521
}
@@ -545,7 +546,7 @@ class SingleDeviceFunctionTracker {
545546
FunctionDecl *SYCLKernel = nullptr;
546547
FunctionDecl *KernelBody = nullptr;
547548
llvm::SmallPtrSet<FunctionDecl *, 16> DeviceFunctions;
548-
llvm::SmallPtrSet<FunctionDecl *, 16> RecursiveFunctions;
549+
llvm::SmallPtrSet<const FunctionDecl *, 16> RecursiveFunctions;
549550
llvm::SmallVector<Attr *> CollectedAttributes;
550551

551552
FunctionDecl *GetFDFromNode(CallGraphNode *Node) {
@@ -3565,6 +3566,17 @@ static void PropagateAndDiagnoseDeviceAttr(Sema &S, Attr *A,
35653566
}
35663567
break;
35673568
}
3569+
case attr::Kind::SYCLSimd:
3570+
if (KernelBody && !KernelBody->getAttr<SYCLSimdAttr>()) {
3571+
// Usual kernel can't call ESIMD functions.
3572+
S.Diag(KernelBody->getLocation(),
3573+
diag::err_sycl_function_attribute_mismatch)
3574+
<< A;
3575+
S.Diag(A->getLocation(), diag::note_attribute);
3576+
KernelBody->setInvalidDecl();
3577+
break;
3578+
}
3579+
LLVM_FALLTHROUGH;
35683580
case attr::Kind::SYCLIntelKernelArgsRestrict:
35693581
case attr::Kind::SYCLIntelNumSimdWorkItems:
35703582
case attr::Kind::SYCLIntelSchedulerTargetFmaxMhz:
@@ -3575,19 +3587,8 @@ static void PropagateAndDiagnoseDeviceAttr(Sema &S, Attr *A,
35753587
case attr::Kind::SYCLIntelFPGAMaxConcurrency:
35763588
case attr::Kind::SYCLIntelFPGADisableLoopPipelining:
35773589
case attr::Kind::SYCLIntelFPGAInitiationInterval:
3578-
case attr::Kind::SYCLSimd: {
3579-
if ((A->getKind() == attr::Kind::SYCLSimd) && KernelBody &&
3580-
!KernelBody->getAttr<SYCLSimdAttr>()) {
3581-
// Usual kernel can't call ESIMD functions.
3582-
S.Diag(KernelBody->getLocation(),
3583-
diag::err_sycl_function_attribute_mismatch)
3584-
<< A;
3585-
S.Diag(A->getLocation(), diag::note_attribute);
3586-
KernelBody->setInvalidDecl();
3587-
} else
3588-
SYCLKernel->addAttr(A);
3590+
SYCLKernel->addAttr(A);
35893591
break;
3590-
}
35913592
// TODO: vec_len_hint should be handled here
35923593
default:
35933594
// Seeing this means that CollectPossibleKernelAttributes was

0 commit comments

Comments
 (0)