Skip to content
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

[SYCL] Do not decompose non-trivial bases with pointers #6964

Merged
merged 2 commits into from
Oct 6, 2022
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
18 changes: 4 additions & 14 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1826,20 +1826,10 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
CollectionStack.back() = true;
PointerStack.pop_back();
} else if (PointerStack.pop_back_val()) {
// FIXME: Stop triggering decomposition for non-trivial types with
// pointers
if (RD->isTrivial()) {
PointerStack.back() = true;
if (!RD->hasAttr<SYCLGenerateNewTypeAttr>())
RD->addAttr(
SYCLGenerateNewTypeAttr::CreateImplicit(SemaRef.getASTContext()));
} else {
// We are visiting a non-trivial type with pointer.
CollectionStack.back() = true;
if (!RD->hasAttr<SYCLRequiresDecompositionAttr>())
RD->addAttr(SYCLRequiresDecompositionAttr::CreateImplicit(
SemaRef.getASTContext()));
}
PointerStack.back() = true;
if (!RD->hasAttr<SYCLGenerateNewTypeAttr>())
RD->addAttr(
SYCLGenerateNewTypeAttr::CreateImplicit(SemaRef.getASTContext()));
}
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion clang/test/CodeGenSYCL/inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class second_base {
public:
int *e;
second_base(int *E) : e(E) {}
};

class InnerFieldBase {
Expand All @@ -23,7 +24,7 @@ struct base {

struct derived : base, second_base {
int a;

derived() : second_base(nullptr) {}
void operator()() const {
}
};
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaSYCL/decomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,6 @@ int main() {
myQueue.submit([&](sycl::handler &h) {
h.single_task<class NonTrivialStructInBase>([=]() { return NonTrivialDerivedStructWithPtr.i;});
});
// CHECK: FunctionDecl {{.*}}NonTrivialStructInBase{{.*}} 'void (__wrapper_class, int, int)'
// CHECK: FunctionDecl {{.*}}NonTrivialStructInBase{{.*}} 'void (__generated_NonTrivialDerived)'
}
}
3 changes: 2 additions & 1 deletion clang/test/SemaSYCL/inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class third_base {
class second_base {
public:
int *e;
second_base(int *E) : e(E) {}
};

class InnerFieldBase {
Expand All @@ -29,7 +30,7 @@ struct base {

struct derived : base, second_base, third_base{
int a;

derived() : second_base(nullptr) {}
void operator()() const {
}
};
Expand Down