[Mlir-commits] [mlir] ca5e2e3 - [mlir-translate] More specific error message for BlockAddress

Min-Yih Hsu llvmlistbot at llvm.org
Wed Jan 25 14:57:12 PST 2023


Author: Arthur Lafrance
Date: 2023-01-25T14:56:28-08:00
New Revision: ca5e2e3aaa3b631b23ae09e99c41da9b42bcce75

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

LOG: [mlir-translate] More specific error message for BlockAddress

BlockAddress is currently unimplemented in the LLVM dialect of MLIR;
when converting to LLVM dialect MLIR from LLVM IR, mlir-translate
currently terminates with an "unhandled constant" error message.
Instead, this message could be made more specific, to let the user know
that the specific issue is that BlockAddress is unimplemented in the
LLVM dialect.

Differential Revision: https://reviews.llvm.org/D142337

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/ModuleImport.cpp
    mlir/test/Target/LLVMIR/Import/import-failure.ll

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 979762e794bce..5391d2e92f45e 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -1062,6 +1062,11 @@ FailureOr<Value> ModuleImport::convertConstant(llvm::Constant *constant) {
     return root;
   }
 
+  if (isa<llvm::BlockAddress>(constant)) {
+    return emitError(loc)
+           << "blockaddress is not implemented in the LLVM dialect";
+  }
+
   return emitError(loc) << "unhandled constant: " << diag(*constant);
 }
 

diff  --git a/mlir/test/Target/LLVMIR/Import/import-failure.ll b/mlir/test/Target/LLVMIR/Import/import-failure.ll
index 0570fe4bdeeb5..79e4e188db0f1 100644
--- a/mlir/test/Target/LLVMIR/Import/import-failure.ll
+++ b/mlir/test/Target/LLVMIR/Import/import-failure.ll
@@ -22,7 +22,7 @@ define i32 @unhandled_value(i32 %arg1) {
 ; // -----
 
 ; CHECK:      import-failure.ll
-; CHECK-SAME: error: unhandled constant: ptr blockaddress(@unhandled_constant, %bb1)
+; CHECK-SAME: error: blockaddress is not implemented in the LLVM dialect
 ; CHECK:      import-failure.ll
 ; CHECK-SAME: error: unhandled instruction: ret ptr blockaddress(@unhandled_constant, %bb1)
 define ptr @unhandled_constant() {
@@ -33,7 +33,7 @@ bb1:
 ; // -----
 
 ; CHECK:      import-failure.ll
-; CHECK-SAME: error: unhandled constant: ptr blockaddress(@unhandled_global, %bb1)
+; CHECK-SAME: error: blockaddress is not implemented in the LLVM dialect
 ; CHECK:      import-failure.ll
 ; CHECK-SAME: error: unhandled global variable: @private = private global ptr blockaddress(@unhandled_global, %bb1)
 @private = private global ptr blockaddress(@unhandled_global, %bb1)


        


More information about the Mlir-commits mailing list