diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -944,11 +944,7 @@ SmallVector scopeMDs; for (SymbolRefAttr scopeRef : scopes.getAsRange()) scopeMDs.push_back(getAliasScope(*op, scopeRef)); - llvm::MDNode *unionMD = nullptr; - if (scopeMDs.size() == 1) - unionMD = llvm::cast(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); }; diff --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -1653,9 +1653,12 @@ // Metadata // CHECK-DAG: ![[DOMAIN:[0-9]+]] = distinct !{![[DOMAIN]], !"The domain"} -// CHECK-DAG: ![[SCOPE1]] = distinct !{![[SCOPE1]], ![[DOMAIN]], !"The first scope"} -// CHECK-DAG: ![[SCOPE2]] = distinct !{![[SCOPE2]], ![[DOMAIN]]} -// CHECK-DAG: ![[SCOPE3]] = distinct !{![[SCOPE3]], ![[DOMAIN]]} +// CHECK-DAG: ![[SCOPE1_NODE:[0-9]+]] = distinct !{![[SCOPE1_NODE]], ![[DOMAIN]], !"The first scope"} +// CHECK-DAG: ![[SCOPE2_NODE:[0-9]+]] = distinct !{![[SCOPE2_NODE]], ![[DOMAIN]]} +// CHECK-DAG: ![[SCOPE3_NODE:[0-9]+]] = distinct !{![[SCOPE3_NODE]], ![[DOMAIN]]} +// CHECK-DAG: ![[SCOPE1]] = !{![[SCOPE1_NODE]]} +// CHECK-DAG: ![[SCOPE2]] = !{![[SCOPE2_NODE]]} +// CHECK-DAG: ![[SCOPE3]] = !{![[SCOPE3_NODE]]} // CHECK-DAG: ![[SCOPES12]] = !{![[SCOPE1]], ![[SCOPE2]]} // CHECK-DAG: ![[SCOPES13]] = !{![[SCOPE1]], ![[SCOPE3]]} // CHECK-DAG: ![[SCOPES23]] = !{![[SCOPE2]], ![[SCOPE3]]}