Skip to content

[SYCL][SemaSYCL] Functor Inheritance Incorrect Outline/CodeGen #488

Closed
@agozillon

Description

@agozillon

The example is a little contrived in this case, but from what I can tell it's all legal SYCL (please correct me if I am wrong though as my Spec-foo still needs a lot of work). I've been looking into it as I'm trying to find a solution for it myself ASAP, although I imagine if I find one it might not be ideal.

#include <CL/sycl.hpp>

struct empty_base_class {};

struct functor : empty_base_class {
  uint16_t foo;
  uint32_t bar;

  void operator()() {
    auto tmp_foo = foo;
    auto tmp_bar = bar;
  }
};

int main() {
  cl::sycl::queue q;

  q.submit([&](cl::sycl::handler &cgh) {
     functor f{};
     cgh.single_task(f);
  });

  return 0;
}

So the above test will result in:

error: Explicit load/store type does not match pointee type of pointer operand (Producer: 'LLVM9.0.0svn' Reader: 'LLVM 9.0.0svn')

From what I can tell, this seems to be a side affect of moving from the illegal assignment style of AST generation to the more legal Initialization method. The InitExprList isn't setup to handle the Base classes initialization, so when it gets to the function VisitInitListExpr: https://github.com/intel/llvm/blob/sycl/clang/lib/CodeGen/CGExprAgg.cpp#L1502

It results in a sort of off by 1 (or off by the number of base classes I suppose) error in the above case where an invalid store is generated because you're matching the wrong Initialization Expr against the wrong destination type. In the above case it'll be something like the store of an i16 vs i32* because of the two uint scalar types being initialized.

You can change the uint types to be the same size/type and you won't get the error, but I believe the IR will not generate all of the required stores (not looked too deeply into that) and I imagine if any type is different it'll result in a similar load/store error.

Worth noting that the error is from a Release mode compilation, in Debug it will probably crash/assert here:
https://github.com/intel/llvm/blob/sycl/clang/lib/CodeGen/CGExprAgg.cpp#L1846

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions