Skip to content

[SYCL] Adjust AUX target with lang options #2295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,10 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
// Adjust target options based on codegen options.
getTarget().adjustTargetOptions(getCodeGenOpts(), getTargetOpts());

if (auto *Aux = getAuxTarget())
if (auto *Aux = getAuxTarget()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the 'createPreprocessor' has a similar target.adjust, does this need to be changed there too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I don't know. I just tried to comment it out and it seems that check-clang passes with such change. Not sure that it has any effect there.
My intention was to find a place where aux target is connected with the current target and adjust aux target there. I found only this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... interesting. While I think it is likely valuable to be in the prepreprocessor function as well, I don't think much happens for the preprocessor for target-specific actions.

That said, if this fixes mlong-double-#, it is likely sufficient.

Aux->adjust(getLangOpts());
getTarget().setAuxTarget(Aux);
}

// rewriter project will change target built-in bool type from its default.
if (getFrontendOpts().ProgramAction == frontend::RewriteObjC)
Expand Down
24 changes: 24 additions & 0 deletions clang/test/SemaSYCL/long-double.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-linux-gnu -fsycl -fsycl-is-device -verify -fsyntax-only %s
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s
// RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only -mlong-double-64 %s

template <typename Name, typename Func>
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
// expected-note@+1 {{called by 'kernel<variables}}
kernelFunc();
}

//expected-note@+1 {{'foo' defined here}}
void foo(long double A) {}

int main() {
//expected-note@+1 {{'CapturedToDevice' defined here}}
long double CapturedToDevice = 1;
kernel<class variables>([=]() {
// expected-error@+2 {{'foo' requires 128 bit size 'long double' type support, but device 'spir64' does not support it}}
// expected-error@+1 {{'CapturedToDevice' requires 128 bit size 'long double' type support, but device 'spir64' does not support it}}
foo(CapturedToDevice);
});

return 0;
}