Skip to content

Commit 3dfbedd

Browse files
committed
[tblgen] Use emitError for inferResultTypes failures
1 parent 9a5ae34 commit 3dfbedd

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

mlir/include/mlir/Interfaces/InferTypeOpInterface.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ inferReturnTensorTypes(ArrayRef<ShapedTypeComponents> retComponents,
245245
/// the op. Precondition: op implements InferTypeOpInterface.
246246
LogicalResult verifyInferredResultTypes(Operation *op);
247247

248-
/// Report a fatal error indicating that the result types could not be
249-
/// inferred.
250-
void reportFatalInferReturnTypesError(OperationState &state);
248+
/// Report an error indicating that the result types could not be inferred.
249+
void emitInferReturnTypesError(OperationState &state);
251250
} // namespace detail
252251

253252
namespace OpTrait {

mlir/lib/Interfaces/InferTypeOpInterface.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,12 @@ LogicalResult mlir::detail::verifyInferredResultTypes(Operation *op) {
240240
return result;
241241
}
242242

243-
void mlir::detail::reportFatalInferReturnTypesError(OperationState &state) {
244-
std::string buffer;
245-
llvm::raw_string_ostream os(buffer);
246-
os << "Failed to infer result type(s):\n"
247-
<< "\"" << state.name << "\"(...) "
248-
<< state.attributes.getDictionary(state.location.getContext()) << " : ("
249-
<< llvm::interleaved(llvm::map_range(
250-
state.operands, [](Value val) { return val.getType(); }))
251-
<< ") -> ( ??? )";
252-
emitRemark(state.location, "location of op");
253-
llvm::report_fatal_error(llvm::StringRef(buffer));
243+
void mlir::detail::emitInferReturnTypesError(OperationState &state) {
244+
mlir::emitError(state.location)
245+
<< "Failed to infer result type(s):\n"
246+
<< "\"" << state.name << "\"(...) "
247+
<< state.attributes.getDictionary(state.location.getContext()) << " : ("
248+
<< llvm::interleaved(llvm::map_range(
249+
state.operands, [](Value val) { return val.getType(); }))
250+
<< ") -> ( ??? )";
254251
}

mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ void OpEmitter::genSeparateArgParamBuilder() {
26812681
{1}.regions, inferredReturnTypes)))
26822682
{1}.addTypes(inferredReturnTypes);
26832683
else
2684-
::mlir::detail::reportFatalInferReturnTypesError({1});
2684+
::mlir::detail::emitInferReturnTypesError({1});
26852685
)",
26862686
opClass.getClassName(), builderOpState);
26872687
return;

0 commit comments

Comments
 (0)