[Mlir-commits] [mlir] [mlir] Fix debug output for passes that modify top-level operation. (PR #80022)

Mehdi Amini llvmlistbot at llvm.org
Tue Jan 30 09:56:56 PST 2024


================
@@ -40,7 +40,9 @@ static void logImpossibleToMatch(const Pattern &pattern) {
 
 /// Log IR after pattern application.
 static Operation *getDumpRootOp(Operation *op) {
-  return op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
+  return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>()
+             ? op
+             : op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
----------------
joker-eph wrote:

If you wish to fix the nullptr, I would likely write it as:

```suggestion
  Operation *isolatedParent = op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
  if (isolatedParent) return isolatedParent;
  return op;
```



https://github.com/llvm/llvm-project/pull/80022


More information about the Mlir-commits mailing list