Skip to content

Commit 43862a3

Browse files
authored
[SYCL] Adjust AUX target with lang options (#2295)
Due to lack of this adjustment some options like -mlong-double-64 didn't have an effect on AUX target and caused incorrect diagnostics.
1 parent ba47915 commit 43862a3

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,10 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
955955
// Adjust target options based on codegen options.
956956
getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());
957957

958-
if (auto *Aux = getAuxTarget())
958+
if (auto *Aux = getAuxTarget()) {
959+
Aux->adjust(getLangOpts());
959960
getTarget().setAuxTarget(Aux);
961+
}
960962

961963
// rewriter project will change target built-in bool type from its default.
962964
if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)

clang/test/SemaSYCL/long-double.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-linux-gnu -fsycl -fsycl-is-device -verify -fsyntax-only %s
2+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s
3+
// RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only -mlong-double-64 %s
4+
5+
template <typename Name, typename Func>
6+
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
7+
// expected-note@+1 {{called by 'kernel<variables}}
8+
kernelFunc();
9+
}
10+
11+
//expected-note@+1 {{'foo' defined here}}
12+
void foo(long double A) {}
13+
14+
int main() {
15+
//expected-note@+1 {{'CapturedToDevice' defined here}}
16+
long double CapturedToDevice = 1;
17+
kernel<class variables>([=]() {
18+
// expected-error@+2 {{'foo' requires 128 bit size 'long double' type support, but device 'spir64' does not support it}}
19+
// expected-error@+1 {{'CapturedToDevice' requires 128 bit size 'long double' type support, but device 'spir64' does not support it}}
20+
foo(CapturedToDevice);
21+
});
22+
23+
return 0;
24+
}

0 commit comments

Comments
 (0)