[llvm-branch-commits] [mlir] 685bcc1 - [mlir:bytecode] Only visit the all regions path if the op has regions

Tobias Hieta via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 10 00:09:48 PDT 2023


Author: River Riddle
Date: 2023-08-10T09:06:20+02:00
New Revision: 685bcc1d732a929e6ad92d63f5f3368726e7830c

URL: https://github.com/llvm/llvm-project/commit/685bcc1d732a929e6ad92d63f5f3368726e7830c
DIFF: https://github.com/llvm/llvm-project/commit/685bcc1d732a929e6ad92d63f5f3368726e7830c.diff

LOG: [mlir:bytecode] Only visit the all regions path if the op has regions

Zero region operations return true for both isBeforeAllRegions and
isAfterAllRegions when using WalkStage. The bytecode walk only
expects region holding operations in the after regions path, so
guard against that.

Added: 
    

Modified: 
    mlir/lib/Bytecode/Writer/IRNumbering.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index 788cf5b201f02b..ef643ca6d74c76 100644
--- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp
+++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
@@ -238,7 +238,7 @@ void IRNumberingState::computeGlobalNumberingState(Operation *rootOp) {
   SmallVector<StackState> opStack;
   rootOp->walk([&](Operation *op, const WalkStage &stage) {
     // After visiting all nested regions, we pop the operation from the stack.
-    if (stage.isAfterAllRegions()) {
+    if (op->getNumRegions() && stage.isAfterAllRegions()) {
       // If no non-isolated uses were found, we can safely mark this operation
       // as isolated from above.
       OperationNumbering *numbering = opStack.pop_back_val().numbering;


        


More information about the llvm-branch-commits mailing list