Skip to content

Commit

Permalink
[SYCL] Do not decompose non-trivial bases with pointers (#6964)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fznamznon authored Oct 6, 2022
1 parent 04928f9 commit 9b02506
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
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

0 comments on commit 9b02506

Please sign in to comment.