This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Fix OpenCL and SPIR version metadata generation.
ClosedPublic

Authored by bader on Jun 15 2017, 4:46 AM.

Event Timeline

bader created this revision.Jun 15 2017, 4:46 AM
yaxunl edited edge metadata.Jun 15 2017, 6:27 AM

LGTM. Thanks.

ahatanak added inline comments.
lib/CodeGen/CodeGenModule.cpp
516

CodeGenTypeCache (CodeGenModule's base class) has member Int32Ty, so I don't think you need to call getInt32Ty here?

bader updated this revision to Diff 102789.Jun 16 2017, 12:51 AM

Applied Akira's comment: re-used cached Int32Ty type.

bader marked an inline comment as done.Jun 16 2017, 12:53 AM
Anastasia added inline comments.Jun 19 2017, 10:04 AM
test/CodeGenOpenCL/spir_version.cl
13

Would the original code produce duplicate version metadata here or is it just for overloaded functions? Would it make sense to add CHECK-NOT to make sure they are not generated twice?

bader added inline comments.Jun 19 2017, 10:16 AM
test/CodeGenOpenCL/spir_version.cl
13

The original code will duplicate the metadata here. Something like:

!opencl.ocl.version = !{!0, !0}

One per global value - function in case.

Existing check is already good enough as it checks exactly for one metadata:

// CHECK-SPIR-CL10-DAG: !opencl.ocl.version = !{[[OCL:![0-9]+]]}

It was passing with buggy code, since test contains exactly one function (i.e. global value). Now we have two global values and fix is required to pass existing check.

Anastasia accepted this revision.Jun 20 2017, 7:13 AM

LGTM! Thanks!

This revision is now accepted and ready to land.Jun 20 2017, 7:13 AM
bader closed this revision.Jun 20 2017, 7:30 AM