[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
This commit is contained in:
Arthur Lafrance
2023-01-25 13:02:16 -08:00
committed by Min-Yih Hsu
parent 46013fc10a
commit ca5e2e3aaa
2 changed files with 7 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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)