30 const char SpirVer[] =
"opencl.spir.version";
31 const char OCLVer[] =
"opencl.ocl.version";
32 const char UsedExt[] =
"opencl.used.extensions";
33 const char UsedOptCoreFeat[] =
"opencl.used.optional.core.features";
34 const char CompilerOptions[] =
"opencl.compiler.options";
35 const char LLVMIdent[] =
"llvm.ident";
40 class AMDGPUUnifyMetadata :
public ModulePass {
44 explicit AMDGPUUnifyMetadata() :
ModulePass(ID) {}
47 bool runOnModule(
Module &M)
override;
60 if (!NamedMD || NamedMD->getNumOperands() <= 1)
64 for (
auto VersionMD : NamedMD->operands()) {
65 assert(VersionMD->getNumOperands() == 2);
66 auto CMajor = mdconst::extract<ConstantInt>(VersionMD->getOperand(0));
68 auto CMinor = mdconst::extract<ConstantInt>(VersionMD->getOperand(1));
70 auto Ver = (VersionMajor * 100) + (VersionMinor * 10);
78 NamedMD->eraseFromParent();
93 if (!NamedMD || NamedMD->getNumOperands() == 1)
97 for (
auto MD : NamedMD->operands())
98 for (
const auto &
Op : MD->operands())
102 NamedMD->eraseFromParent();
104 for (
const auto &MD : All)
118 "Unify multiple OpenCL metadata due to linking",
122 return new AMDGPUUnifyMetadata();
125 bool AMDGPUUnifyMetadata::runOnModule(
Module &M) {
126 const char* Vers[] = {
130 const char* Exts[] = {
132 kOCLMD::UsedOptCoreFeat,
133 kOCLMD::CompilerOptions,
137 bool Changed =
false;
140 Changed |= unifyVersionMD(M,
I,
true);
143 Changed |= unifyExtensionMD(M,
I);
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void push_back(const T &Elt)
void addOperand(MDNode *M)
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
LLVMContext & getContext() const
Get the global data context.
char & AMDGPUUnifyMetadataID
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
constexpr uint32_t VersionMinor
HSA metadata minor version.
ModulePass * createAMDGPUUnifyMetadataPass()
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
constexpr uint32_t VersionMajor
HSA metadata major version.