[mlir][llvm] Add experimental alias scope decl intrinsic.

The revision adds the llvm.experimental.noalias.scope.decl intrinsic
to the LLVM dialect and updates the import and export accordingly.

Reviewed By: Dinistro

Differential Revision: https://reviews.llvm.org/D146504
This commit is contained in:
Tobias Gysi
2023-03-22 10:20:55 +01:00
parent 9297b9f8ee
commit 56d94a90db
9 changed files with 137 additions and 53 deletions

View File

@@ -1065,16 +1065,22 @@ ModuleTranslation::getAliasScope(Operation *op,
return aliasScopeMetadataMapping.lookup(aliasScopeOp);
}
llvm::MDNode *ModuleTranslation::getAliasScopes(
Operation *op, ArrayRef<SymbolRefAttr> aliasScopeRefs) const {
SmallVector<llvm::Metadata *> nodes;
nodes.reserve(aliasScopeRefs.size());
for (SymbolRefAttr aliasScopeRef : aliasScopeRefs)
nodes.push_back(getAliasScope(op, aliasScopeRef));
return llvm::MDNode::get(getLLVMContext(), nodes);
}
void ModuleTranslation::setAliasScopeMetadata(AliasAnalysisOpInterface op,
llvm::Instruction *inst) {
auto populateScopeMetadata = [&](ArrayAttr scopeRefs, unsigned kind) {
if (!scopeRefs || scopeRefs.empty())
auto populateScopeMetadata = [&](ArrayAttr aliasScopeRefs, unsigned kind) {
if (!aliasScopeRefs || aliasScopeRefs.empty())
return;
llvm::Module *module = inst->getModule();
SmallVector<llvm::Metadata *> scopeMDs;
for (SymbolRefAttr scopeRef : scopeRefs.getAsRange<SymbolRefAttr>())
scopeMDs.push_back(getAliasScope(op, scopeRef));
llvm::MDNode *node = llvm::MDNode::get(module->getContext(), scopeMDs);
llvm::MDNode *node = getAliasScopes(
op, llvm::to_vector(aliasScopeRefs.getAsRange<SymbolRefAttr>()));
inst->setMetadata(kind, node);
};