Skip to content

Commit 87cb866

Browse files
committed
address review comments
Signed-off-by: Soumi Manna <[email protected]>
1 parent fca61c5 commit 87cb866

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12971,15 +12971,12 @@ void Sema::addIntelSYCLSingleArgFunctionAttr(Decl *D,
1297112971
return;
1297212972
}
1297312973
}
12974-
if (CI.getParsedKind() == ParsedAttr::AT_SYCLIntelMaxGlobalWorkDim ||
12975-
CI.getParsedKind() == ParsedAttr::AT_SYCLIntelNoGlobalWorkOffset) {
12974+
if (CI.getParsedKind() == ParsedAttr::AT_SYCLIntelMaxGlobalWorkDim) {
1297612975
if (ArgInt < 0) {
1297712976
Diag(E->getExprLoc(), diag::err_attribute_requires_positive_integer)
1297812977
<< CI.getAttrName() << /*non-negative*/ 1;
1297912978
return;
1298012979
}
12981-
}
12982-
if (CI.getParsedKind() == ParsedAttr::AT_SYCLIntelMaxGlobalWorkDim) {
1298312980
if (ArgInt > 3) {
1298412981
Diag(E->getBeginLoc(), diag::err_attribute_argument_out_of_range)
1298512982
<< CI.getAttrName() << 0 << 3 << E->getSourceRange();

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ void CodeGenFunction::EmitOpenCLKernelMetadata(const FunctionDecl *FD,
699699
Optional<llvm::APSInt> ArgVal =
700700
Arg->getIntegerConstantExpr(FD->getASTContext());
701701
assert(ArgVal.hasValue() && "Not an integer constant expression");
702-
if (ArgVal)
702+
if (ArgVal->getBoolValue())
703703
Fn->setMetadata("no_global_work_offset", llvm::MDNode::get(Context, {}));
704704
}
705705

clang/test/SemaSYCL/intel-fpga-no-global-work-offset.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int main() {
2626
h.single_task<class test_kernel3>(
2727
[]() [[intel::no_global_work_offset(42)]]{});
2828

29-
// expected-error@+2{{'no_global_work_offset' attribute requires a non-negative integral compile time constant expression}}
29+
// CHECK: SYCLIntelNoGlobalWorkOffsetAttr{{.*}}
3030
h.single_task<class test_kernel4>(
3131
[]() [[intel::no_global_work_offset(-1)]]{});
3232

clang/test/SemaSYCL/sycl-device-intel-fpga-no-global-work-offset.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
// Test that checks template parameter support for 'no_global_work_offset' attribute on sycl device.
44

5-
// Test that checks wrong template instantiation.
5+
// Test that checks wrong function template instantiation and ensures that the type
6+
// is checked properly when instantiating from the template definition.
67
template <typename Ty>
8+
// expected-error@+1{{'no_global_work_offset' attribute requires an integer constant}}
79
[[intel::no_global_work_offset(Ty{})]] void func() {}
810

911
struct S {};
10-
// expected-error@+2{{template specialization requires 'template<>'}}
11-
// expected-error@+1{{C++ requires a type specifier for all declarations}}
12-
func<S>();
12+
void var() {
13+
//expected-note@+1{{in instantiation of function template specialization 'func<S>' requested here}}
14+
func<S>();
15+
}
1316

1417
// Test that checks expression is not a constant expression.
1518
int foo();
@@ -24,14 +27,10 @@ constexpr int bar() { return 0; }
2427
template <int SIZE>
2528
class KernelFunctor {
2629
public:
27-
// expected-error@+1{{'no_global_work_offset' attribute requires a non-negative integral compile time constant expression}}
2830
[[intel::no_global_work_offset(SIZE)]] void operator()() {}
2931
};
3032

3133
int main() {
32-
//expected-note@+1{{in instantiation of template class 'KernelFunctor<-1>' requested here}}
33-
KernelFunctor<-1>();
34-
// no error expected
3534
KernelFunctor<1>();
3635
}
3736

0 commit comments

Comments
 (0)