triSYCL / sycl

SYCL for Vitis: Experimental fusion of triSYCL with Intel SYCL oneAPI DPC++ up-streaming effort into Clang/LLVM
Other
107 stars 19 forks source link

Aggregate initialization crashes opt #206

Closed gogo2 closed 1 year ago

gogo2 commented 1 year ago

Problem description

When I try to compile such code:

struct Line {
    float slope;
    float intercept;
};

int main() {
    sycl::queue queue{};
    {
        queue.submit([&](sycl::handler &cgh) {
            cgh.single_task([]() {
                Line l1{0, 0};
            });
        });
    }
}

it fails with a opt crash in sycl->HLS conversion step ("Error in sycl->HLS conversion").

It works if I disable aggregate initialization by defining construstor Line(float s, float i) : slope{s}, intercept{i} {} or using default member initializer float intercept = 0.

But the interesting thing is that it also works if pass something other than zeros to aggregate:

Line l1{0, 1};

I believe this also affects std::array.

Any chance for fixing this issue or at least some hint on where to look?

Setup

Ralender commented 1 year ago

https://github.com/triSYCL/sycl/pull/207 should fix this issue.

explanation of the bug: LLVM loves making anything it can into a memset but memset are handled poorly by the HLS backend. so our passes will turn memset back into stores of constants. there was a bug in generation of constant that need to be stored. it doesn't happened for {0, 1} because it cannot be turned into a memset.

gogo2 commented 1 year ago

This fix does the job for this issue, many thanks for help!