Go to the documentation of this file.
26 const char SpirVer[] =
"opencl.spir.version";
27 const char OCLVer[] =
"opencl.ocl.version";
28 const char UsedExt[] =
"opencl.used.extensions";
29 const char UsedOptCoreFeat[] =
"opencl.used.optional.core.features";
30 const char CompilerOptions[] =
"opencl.compiler.options";
31 const char LLVMIdent[] =
"llvm.ident";
36 class AMDGPUUnifyMetadata :
public ModulePass {
43 bool runOnModule(
Module &M)
override;
56 auto NamedMD =
M.getNamedMetadata(
Name);
57 if (!NamedMD || NamedMD->getNumOperands() <= 1)
61 for (
auto VersionMD : NamedMD->operands()) {
62 assert(VersionMD->getNumOperands() == 2);
63 auto CMajor = mdconst::extract<ConstantInt>(VersionMD->getOperand(0));
65 auto CMinor = mdconst::extract<ConstantInt>(VersionMD->getOperand(1));
75 NamedMD->eraseFromParent();
76 NamedMD =
M.getOrInsertNamedMetadata(
Name);
77 NamedMD->addOperand(MaxMD);
89 auto NamedMD =
M.getNamedMetadata(
Name);
90 if (!NamedMD || NamedMD->getNumOperands() == 1)
94 for (
auto MD : NamedMD->operands())
95 for (
const auto &
Op : MD->operands())
97 All.push_back(
Op.get());
99 NamedMD->eraseFromParent();
100 NamedMD =
M.getOrInsertNamedMetadata(
Name);
101 for (
const auto &MD : All)
107 bool unifyMetadataImpl(
Module &M) {
108 const char *Vers[] = {kOCLMD::SpirVer, kOCLMD::OCLVer};
109 const char *Exts[] = {kOCLMD::UsedExt, kOCLMD::UsedOptCoreFeat,
110 kOCLMD::CompilerOptions, kOCLMD::LLVMIdent};
112 bool Changed =
false;
115 Changed |= unifyVersionMD(M,
I,
true);
118 Changed |= unifyExtensionMD(M,
I);
130 "Unify multiple OpenCL metadata due to linking",
false,
false)
133 return new AMDGPUUnifyMetadata();
136 bool AMDGPUUnifyMetadata::runOnModule(
Module &M) {
137 return unifyMetadataImpl(M);
A set of analyses that are preserved following a run of a transformation pass.
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
char & AMDGPUUnifyMetadataID
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
ModulePass * createAMDGPUUnifyMetadataPass()
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
constexpr uint32_t VersionMajor
HSA metadata major version.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
constexpr uint32_t VersionMinor
HSA metadata minor version.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A Module instance is used to store all the information related to an LLVM module.
StringRef - Represent a constant reference to a string, i.e.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A container for analyses that lazily runs them and caches their results.