[AMDGPU] Add amdgpu-unify-metadata pass
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 8 Dec 2016 19:46:04 +0000 (19:46 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 8 Dec 2016 19:46:04 +0000 (19:46 +0000)
commit50ea93a2bda4b4a5a4ea7a879182d0c0cf2f002c
treef7fbd02e0f3afa3750b907c336b7f399525ecdcf
parent64135c35f771c4d0fb9f01e05d167df0d0445710
[AMDGPU] Add amdgpu-unify-metadata pass

Multiple metadata values for records such as opencl.ocl.version, llvm.ident
and similar are created after linking several modules. For some of them, notably
opencl.ocl.version, this creates semantic problem because we cannot tell which
version of OpenCL the composite module conforms.

Moreover, such repetitions of identical values often create a huge list of
unneeded metadata, which grows bitcode size both in memory and stored on disk.
It can go up to several Mb when linked against our OpenCL library. Lastly, such
long lists obscure reading of dumped IR.

The pass unifies metadata after linking.

Differential Revision: https://reviews.llvm.org/D25381

llvm-svn: 289092
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
llvm/lib/Target/AMDGPU/AMDGPUUnifyMetadata.cpp [new file with mode: 0644]
llvm/lib/Target/AMDGPU/CMakeLists.txt
llvm/test/CodeGen/AMDGPU/unify-metadata.ll [new file with mode: 0644]