summaryrefslogtreecommitdiff
path: root/mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
diff options
context:
space:
mode:
authorAiden Grossman <aidengrossman@google.com>2025-10-30 15:40:05 +0000
committerAiden Grossman <aidengrossman@google.com>2025-10-30 15:40:05 +0000
commit23de60b719e5e4cc128c42c187d7d26201ced57e (patch)
tree1ad7cab7731169ee4ecad6b11e46ff8a71b94f45 /mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
parent1b2f3728e537f008cfb6b03bd603ea309194f453 (diff)
parentd09b50596d27d48d0a0cbf9bfe5f121e85de7313 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/boomanaiden154/main.msan-make-test-work-with-internal-shell
Created using spr 1.3.7 [skip ci]
Diffstat (limited to 'mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp')
-rw-r--r--mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp b/mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
index f1aae15393fd..2e6950fca6be 100644
--- a/mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
+++ b/mlir/unittests/Interfaces/ControlFlowInterfacesTest.cpp
@@ -13,17 +13,24 @@
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Parser/Parser.h"
+#include "llvm/Support/DebugLog.h"
#include <gtest/gtest.h>
using namespace mlir;
/// A dummy op that is also a terminator.
-struct DummyOp : public Op<DummyOp, OpTrait::IsTerminator> {
+struct DummyOp : public Op<DummyOp, OpTrait::IsTerminator, OpTrait::ZeroResults,
+ OpTrait::ZeroSuccessors,
+ RegionBranchTerminatorOpInterface::Trait> {
using Op::Op;
static ArrayRef<StringRef> getAttributeNames() { return {}; }
static StringRef getOperationName() { return "cftest.dummy_op"; }
+
+ MutableOperandRange getMutableSuccessorOperands(RegionSuccessor point) {
+ return MutableOperandRange(getOperation(), 0, 0);
+ }
};
/// All regions of this op are mutually exclusive.
@@ -39,6 +46,8 @@ struct MutuallyExclusiveRegionsOp
// Regions have no successors.
void getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> &regions) {}
+ using RegionBranchOpInterface::Trait<
+ MutuallyExclusiveRegionsOp>::getSuccessorRegions;
};
/// All regions of this op call each other in a large circle.
@@ -53,13 +62,18 @@ struct LoopRegionsOp
void getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> &regions) {
- if (Region *region = point.getRegionOrNull()) {
- if (point == (*this)->getRegion(1))
+ if (point.getTerminatorPredecessorOrNull()) {
+ Region *region =
+ point.getTerminatorPredecessorOrNull()->getParentRegion();
+ if (region == &(*this)->getRegion(1))
// This region also branches back to the parent.
- regions.push_back(RegionSuccessor());
+ regions.push_back(
+ RegionSuccessor(getOperation()->getParentOp(),
+ getOperation()->getParentOp()->getResults()));
regions.push_back(RegionSuccessor(region));
}
}
+ using RegionBranchOpInterface::Trait<LoopRegionsOp>::getSuccessorRegions;
};
/// Each region branches back it itself or the parent.
@@ -75,11 +89,17 @@ struct DoubleLoopRegionsOp
void getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> &regions) {
- if (Region *region = point.getRegionOrNull()) {
- regions.push_back(RegionSuccessor());
+ if (point.getTerminatorPredecessorOrNull()) {
+ Region *region =
+ point.getTerminatorPredecessorOrNull()->getParentRegion();
+ regions.push_back(
+ RegionSuccessor(getOperation()->getParentOp(),
+ getOperation()->getParentOp()->getResults()));
regions.push_back(RegionSuccessor(region));
}
}
+ using RegionBranchOpInterface::Trait<
+ DoubleLoopRegionsOp>::getSuccessorRegions;
};
/// Regions are executed sequentially.
@@ -93,11 +113,15 @@ struct SequentialRegionsOp
// Region 0 has Region 1 as a successor.
void getSuccessorRegions(RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> &regions) {
- if (point == (*this)->getRegion(0)) {
+ if (point.getTerminatorPredecessorOrNull() &&
+ point.getTerminatorPredecessorOrNull()->getParentRegion() ==
+ &(*this)->getRegion(0)) {
Operation *thisOp = this->getOperation();
regions.push_back(RegionSuccessor(&thisOp->getRegion(1)));
}
}
+ using RegionBranchOpInterface::Trait<
+ SequentialRegionsOp>::getSuccessorRegions;
};
/// A dialect putting all the above together.