https://reviews.llvm.org/D53809 fixed wrong address space(assert in debug build)
generated for event_ret argument. But exactly the same problem exists for
event_wait_list argument. This patch should fix both.
Details
- Reviewers
Anastasia yaxunl - Commits
- rG1b01f9728f9b: [OpenCL] Re-fix invalid address space generation for clk_event_t arguments of…
rC358151: [OpenCL] Re-fix invalid address space generation for clk_event_t arguments of…
rL358151: [OpenCL] Re-fix invalid address space generation for clk_event_t arguments of…
Diff Detail
Event Timeline
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3704 | It seems we are not testing the casts? |
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3704 | Do you mean that when we run LIT tests, this code is not executed? If so, in the modified test below, literal zeros are making clang to execute CreateIntToPtr call indeed. |
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3704 | I mean since you are generating extra IR nodes we should check in the tests that they appear correctly. I don't see these casts checked in the tests currently. |
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3704 | Since we are casting null constants they are folded to null values, like this %opencl.clk_event_t{{.*}}* addrspace(4)* null. |
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3704 | I think 0 is the only possible integral literal, which can be given as the events arguments. |
Alternative way to fix it is to use isNullPointerConstant like we do in SemaOpenCLBuiltinEnqueueKernel. So in case we have a zero literal value we can emit ConstantPointerNull directly, without EmitScalarExpr .
It must be rejected by SemaOpenCLBuiltinEnqueueKernel and it is already done https://godbolt.org/z/MFN3VU
The patch has been updated. Now it checks if the argument isNullPointerConstant and emits null pointer directly in this case.
LGTM! Great! Thanks!
lib/CodeGen/CGBuiltin.cpp | ||
---|---|---|
3709 | Just a minor issue of style, you could probably use a common lambda helper here. Although it's only used in this two places so definitely not that critical. It might be helpful mainly if we need to fix something later... |
It seems we are not testing the casts?