[mlir] Always create a list of alias scopes when emitting LLVM IR

Previously, the translation to LLVM IR would emit IR that directly uses
a scope metadata node in case only one scope was in use in alias.scopes
or noalias metadata. It should always be a list of scopes. The verifier
change in 8700f2bd36 enforced this and
broke the test. Fix the translation to always create a list of scopes
using a new metadata node, update and reenable the respective test.

Fixes PR51919.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D110140
This commit is contained in:
Alex Zinenko
2021-09-21 11:39:43 +02:00
parent b81e26c7f4
commit bdaf038266
2 changed files with 10 additions and 13 deletions

View File

@@ -944,11 +944,7 @@ void ModuleTranslation::setAliasScopeMetadata(Operation *op,
SmallVector<llvm::Metadata *> scopeMDs;
for (SymbolRefAttr scopeRef : scopes.getAsRange<SymbolRefAttr>())
scopeMDs.push_back(getAliasScope(*op, scopeRef));
llvm::MDNode *unionMD = nullptr;
if (scopeMDs.size() == 1)
unionMD = llvm::cast<llvm::MDNode>(scopeMDs.front());
else if (scopeMDs.size() >= 2)
unionMD = llvm::MDNode::get(module->getContext(), scopeMDs);
llvm::MDNode *unionMD = llvm::MDNode::get(module->getContext(), scopeMDs);
inst->setMetadata(module->getMDKindID(llvmMetadataName), unionMD);
};