[mlir] Reduce call stack depth in LogicalResult. NFC.
authorJakub Kuderski <kubak@google.com>
Tue, 4 Oct 2022 01:58:48 +0000 (21:58 -0400)
committerJakub Kuderski <kubak@google.com>
Tue, 4 Oct 2022 01:59:02 +0000 (21:59 -0400)
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

mlir/include/mlir/Support/LogicalResult.h

index d603777..e3163fe 100644 (file)
@@ -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) {}