Skip to content

Commit 9b02506

Browse files
authored
[SYCL] Do not decompose non-trivial bases with pointers (#6964)
1 parent 04928f9 commit 9b02506

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,20 +1826,10 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
18261826
CollectionStack.back() = true;
18271827
PointerStack.pop_back();
18281828
} else if (PointerStack.pop_back_val()) {
1829-
// FIXME: Stop triggering decomposition for non-trivial types with
1830-
// pointers
1831-
if (RD->isTrivial()) {
1832-
PointerStack.back() = true;
1833-
if (!RD->hasAttr<SYCLGenerateNewTypeAttr>())
1834-
RD->addAttr(
1835-
SYCLGenerateNewTypeAttr::CreateImplicit(SemaRef.getASTContext()));
1836-
} else {
1837-
// We are visiting a non-trivial type with pointer.
1838-
CollectionStack.back() = true;
1839-
if (!RD->hasAttr<SYCLRequiresDecompositionAttr>())
1840-
RD->addAttr(SYCLRequiresDecompositionAttr::CreateImplicit(
1841-
SemaRef.getASTContext()));
1842-
}
1829+
PointerStack.back() = true;
1830+
if (!RD->hasAttr<SYCLGenerateNewTypeAttr>())
1831+
RD->addAttr(
1832+
SYCLGenerateNewTypeAttr::CreateImplicit(SemaRef.getASTContext()));
18431833
}
18441834
return true;
18451835
}

clang/test/CodeGenSYCL/inheritance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class second_base {
66
public:
77
int *e;
8+
second_base(int *E) : e(E) {}
89
};
910

1011
class InnerFieldBase {
@@ -23,7 +24,7 @@ struct base {
2324

2425
struct derived : base, second_base {
2526
int a;
26-
27+
derived() : second_base(nullptr) {}
2728
void operator()() const {
2829
}
2930
};

clang/test/SemaSYCL/decomposition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,6 @@ int main() {
212212
myQueue.submit([&](sycl::handler &h) {
213213
h.single_task<class NonTrivialStructInBase>([=]() { return NonTrivialDerivedStructWithPtr.i;});
214214
});
215-
// CHECK: FunctionDecl {{.*}}NonTrivialStructInBase{{.*}} 'void (__wrapper_class, int, int)'
215+
// CHECK: FunctionDecl {{.*}}NonTrivialStructInBase{{.*}} 'void (__generated_NonTrivialDerived)'
216216
}
217217
}

clang/test/SemaSYCL/inheritance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class third_base {
1111
class second_base {
1212
public:
1313
int *e;
14+
second_base(int *E) : e(E) {}
1415
};
1516

1617
class InnerFieldBase {
@@ -29,7 +30,7 @@ struct base {
2930

3031
struct derived : base, second_base, third_base{
3132
int a;
32-
33+
derived() : second_base(nullptr) {}
3334
void operator()() const {
3435
}
3536
};

0 commit comments

Comments
 (0)