[Mlir-commits] [mlir] bdaf038 - [mlir] Always create a list of alias scopes when emitting LLVM IR

Alex Zinenko llvmlistbot at llvm.org
Tue Sep 21 15:00:53 PDT 2021


Author: Alex Zinenko
Date: 2021-09-22T00:00:46+02:00
New Revision: bdaf038266c28a67bce83491dafd6752e53d4e33

URL: https://github.com/llvm/llvm-project/commit/bdaf038266c28a67bce83491dafd6752e53d4e33
DIFF: https://github.com/llvm/llvm-project/commit/bdaf038266c28a67bce83491dafd6752e53d4e33.diff

LOG: [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 8700f2bd36bb9b7d7075ed4dac0aef92b9489237 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

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    mlir/test/Target/LLVMIR/llvmir.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index cadc2f0e32fbc..e67fda6e0ab63 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -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);
   };
 

diff  --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index 205308754cc92..f020840ce4a13 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1,6 +1,4 @@
 // RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
-// This is failing the LLVM verifier after 8700f2bd36bb9b
-// XFAIL: *
 
 // CHECK: @global_aligned32 = private global i64 42, align 32
 "llvm.mlir.global"() ({}) {sym_name = "global_aligned32", type = i64, value = 42 : i64, linkage = #llvm.linkage<private>, alignment = 32} : () -> ()
@@ -1649,15 +1647,18 @@ module {
 
 // Function
 // CHECK-LABEL: aliasScope
-// CHECK:  store {{.*}}, !alias.scope ![[SCOPE1:[0-9]+]], !noalias ![[SCOPES23:[0-9]+]]
-// CHECK:  store {{.*}}, !alias.scope ![[SCOPE2:[0-9]+]], !noalias ![[SCOPES13:[0-9]+]]
-// CHECK:  load {{.*}},  !alias.scope ![[SCOPE3:[0-9]+]], !noalias ![[SCOPES12:[0-9]+]]
+// CHECK:  store {{.*}}, !alias.scope ![[SCOPES1:[0-9]+]], !noalias ![[SCOPES23:[0-9]+]]
+// CHECK:  store {{.*}}, !alias.scope ![[SCOPES2:[0-9]+]], !noalias ![[SCOPES13:[0-9]+]]
+// CHECK:  load {{.*}},  !alias.scope ![[SCOPES3:[0-9]+]], !noalias ![[SCOPES12:[0-9]+]]
 
 // 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:[0-9]+]] = distinct !{![[SCOPE1]], ![[DOMAIN]], !"The first scope"}
+// CHECK-DAG: ![[SCOPE2:[0-9]+]] = distinct !{![[SCOPE2]], ![[DOMAIN]]}
+// CHECK-DAG: ![[SCOPE3:[0-9]+]] = distinct !{![[SCOPE3]], ![[DOMAIN]]}
+// CHECK-DAG: ![[SCOPES1]] = !{![[SCOPE1]]}
+// CHECK-DAG: ![[SCOPES2]] = !{![[SCOPE2]]}
+// CHECK-DAG: ![[SCOPES3]] = !{![[SCOPE3]]}
 // CHECK-DAG: ![[SCOPES12]] = !{![[SCOPE1]], ![[SCOPE2]]}
 // CHECK-DAG: ![[SCOPES13]] = !{![[SCOPE1]], ![[SCOPE3]]}
 // CHECK-DAG: ![[SCOPES23]] = !{![[SCOPE2]], ![[SCOPE3]]}


        


More information about the Mlir-commits mailing list