Since we don't have an ideal option for ndrange_t implementation (which was discussed there: https://reviews.llvm.org/D23086), I propose to stick with identification by name approach suggested by @Anastasia (solution 2 from the last comment of the discussion - http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160815/168540.html).
We take implementation of ndrange_t from lib/Headers/opencl-c.h and we perform identification of the type by its name.
I think following standard Clang CodeGen convention we should add byval attribute for structs.
However, I am not sure if the best approach would be to use classifyType(...) of ABIInfo and then check what type of argument passing ABIArgInfo returns (direct/indirect/byval). Based on this we could add an attr llvm::Attribute::ByVal to the argument. Perhaps, this should be done with all arguments then. Or I am wondering if better approach would be to just use GetOrCreateLLVMFunction() helper from CodeGen!
Does anyone have any suggestion here?