Strip opencl.ocl.version metadata

This should be uniqued when linking, but right now it creates
a lot of metadata spam listing the same version. This should also
probably be reporting the compiled version of the user program,
which may differ from the library. Currently the library IR files report
1.0 while 1.1/1.2 are the default for user programs.

llvm-svn: 279692
This commit is contained in:
Matt Arsenault 2016-08-25 00:25:10 +00:00
parent 72ae62c1c0
commit 7ef7e6aacd
1 changed files with 7 additions and 0 deletions

View File

@ -57,6 +57,13 @@ int main(int argc, char **argv) {
return 1;
}
// Strip the OpenCL version metadata. There are a lot of linked
// modules in the library build, each spamming the same
// version. This may also report a different version than the user
// program is using. This should probably be uniqued when linking.
if (NamedMDNode *OCLVersion = M->getNamedMetadata("opencl.ocl.version"))
M->eraseNamedMetadata(OCLVersion);
// Set linkage of every external definition to linkonce_odr.
for (Module::iterator i = M->begin(), e = M->end(); i != e; ++i) {
if (!i->isDeclaration() && i->getLinkage() == GlobalValue::ExternalLinkage)