[Mlir-commits] [mlir] 247c84a - [mlir] Reduce call stack depth in LogicalResult. NFC.

Jakub Kuderski llvmlistbot at llvm.org
Mon Oct 3 19:00:34 PDT 2022


Author: Jakub Kuderski
Date: 2022-10-03T21:59:02-04:00
New Revision: 247c84aef6eb8266a9c286f9bbde5f7bb0588cbc

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

LOG: [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

Added: 
    

Modified: 
    mlir/include/mlir/Support/LogicalResult.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Support/LogicalResult.h b/mlir/include/mlir/Support/LogicalResult.h
index d603777f4394d..e3163fe431e52 100644
--- a/mlir/include/mlir/Support/LogicalResult.h
+++ b/mlir/include/mlir/Support/LogicalResult.h
@@ -34,14 +34,14 @@ struct [[nodiscard]] LogicalResult {
   /// 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) {}


        


More information about the Mlir-commits mailing list