From: Jakub Kuderski Date: Tue, 4 Oct 2022 01:58:48 +0000 (-0400) Subject: [mlir] Reduce call stack depth in LogicalResult. NFC. X-Git-Tag: upstream/17.0.6~31705 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=247c84aef6eb8266a9c286f9bbde5f7bb0588cbc;p=platform%2Fupstream%2Fllvm.git [mlir] Reduce call stack depth in LogicalResult. NFC. When debuging a crash or conversion failure in a deep pass pipeline, there are often many interleaved frames with `failed` and `succeeded`. `LogicalResult` is used through the pass infrastructure, so by not implementing failure in terms of a call to succeess, this patch noticeably reduces the total total call stack depth and improves the debugging experience. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D135116 --- diff --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h index d603777..e3163fe 100644 --- a/mlir/include/mlir/Support/LogicalResult.h +++ b/mlir/include/mlir/Support/LogicalResult.h @@ -34,14 +34,14 @@ public: /// If isFailure is true a `failure` result is generated, otherwise a /// 'success' result is generated. static LogicalResult failure(bool isFailure = true) { - return success(!isFailure); + return LogicalResult(!isFailure); } /// Returns true if the provided LogicalResult corresponds to a success value. bool succeeded() const { return isSuccess; } /// Returns true if the provided LogicalResult corresponds to a failure value. - bool failed() const { return !succeeded(); } + bool failed() const { return !isSuccess; } private: LogicalResult(bool isSuccess) : isSuccess(isSuccess) {}