-
Notifications
You must be signed in to change notification settings - Fork 15k
[CIR] Fix building ClangIR after RegionBranchOpInterface revamp #165441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+22
−14
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Amr Hesham (AmrDeveloper) ChangesFix building ClangIR after RegionBranchOpInterface revamp (#165429) Full diff: https://github.com/llvm/llvm-project/pull/165441.diff 2 Files Affected:
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 2d2ef422bfaef..7ba03ce40140c 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -286,14 +286,14 @@ void cir::ConditionOp::getSuccessorRegions(
// Parent is a loop: condition may branch to the body or to the parent op.
if (auto loopOp = dyn_cast<LoopOpInterface>(getOperation()->getParentOp())) {
regions.emplace_back(&loopOp.getBody(), loopOp.getBody().getArguments());
- regions.emplace_back(loopOp->getResults());
+ regions.emplace_back(getOperation(), loopOp->getResults());
}
assert(!cir::MissingFeatures::awaitOp());
}
MutableOperandRange
-cir::ConditionOp::getMutableSuccessorOperands(RegionBranchPoint point) {
+cir::ConditionOp::getMutableSuccessorOperands(RegionSuccessor point) {
// No values are yielded to the successor region.
return MutableOperandRange(getOperation(), 0, 0);
}
@@ -989,7 +989,8 @@ void cir::IfOp::getSuccessorRegions(mlir::RegionBranchPoint point,
SmallVectorImpl<RegionSuccessor> ®ions) {
// The `then` and the `else` region branch back to the parent operation.
if (!point.isParent()) {
- regions.push_back(RegionSuccessor());
+ regions.push_back(
+ RegionSuccessor(getOperation(), getOperation()->getResults()));
return;
}
@@ -1039,7 +1040,7 @@ void cir::ScopeOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
// The only region always branch back to the parent operation.
if (!point.isParent()) {
- regions.push_back(RegionSuccessor(getODSResults(0)));
+ regions.push_back(RegionSuccessor(getOperation(), getODSResults(0)));
return;
}
@@ -1124,7 +1125,8 @@ Block *cir::BrCondOp::getSuccessorForOperands(ArrayRef<Attribute> operands) {
void cir::CaseOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
if (!point.isParent()) {
- regions.push_back(RegionSuccessor());
+ regions.push_back(
+ RegionSuccessor(getOperation(), getOperation()->getResults()));
return;
}
regions.push_back(RegionSuccessor(&getCaseRegion()));
@@ -1188,7 +1190,8 @@ static void printSwitchOp(OpAsmPrinter &p, cir::SwitchOp op,
void cir::SwitchOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ion) {
if (!point.isParent()) {
- region.push_back(RegionSuccessor());
+ region.push_back(
+ RegionSuccessor(getOperation(), getOperation()->getResults()));
return;
}
@@ -1402,7 +1405,8 @@ void cir::GlobalOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
// The `ctor` and `dtor` regions always branch back to the parent operation.
if (!point.isParent()) {
- regions.push_back(RegionSuccessor());
+ regions.push_back(
+ RegionSuccessor(getOperation(), getOperation()->getResults()));
return;
}
@@ -1961,7 +1965,7 @@ void cir::TernaryOp::getSuccessorRegions(
mlir::RegionBranchPoint point, SmallVectorImpl<RegionSuccessor> ®ions) {
// The `true` and the `false` region branch back to the parent operation.
if (!point.isParent()) {
- regions.push_back(RegionSuccessor(this->getODSResults(0)));
+ regions.push_back(RegionSuccessor(getOperation(), this->getODSResults(0)));
return;
}
@@ -2978,7 +2982,8 @@ void cir::TryOp::getSuccessorRegions(
llvm::SmallVectorImpl<mlir::RegionSuccessor> ®ions) {
// The `try` and the `catchers` region branch back to the parent operation.
if (!point.isParent()) {
- regions.push_back(mlir::RegionSuccessor());
+ regions.push_back(
+ RegionSuccessor(getOperation(), getOperation()->getResults()));
return;
}
diff --git a/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp b/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp
index 0ce5017a399da..0fbfbea828db4 100644
--- a/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp
+++ b/clang/lib/CIR/Interfaces/CIRLoopOpInterface.cpp
@@ -17,7 +17,7 @@ namespace cir {
void LoopOpInterface::getLoopOpSuccessorRegions(
LoopOpInterface op, mlir::RegionBranchPoint point,
llvm::SmallVectorImpl<mlir::RegionSuccessor> ®ions) {
- assert(point.isParent() || point.getRegionOrNull());
+ assert(point.isParent() || point.getTerminatorPredecessorOrNull());
// Branching to first region: go to condition or body (do-while).
if (point.isParent()) {
@@ -26,14 +26,16 @@ void LoopOpInterface::getLoopOpSuccessorRegions(
}
// Branching from condition: go to body or exit.
- if (&op.getCond() == point.getRegionOrNull()) {
- regions.emplace_back(mlir::RegionSuccessor(op->getResults()));
+ if (&op.getCond() ==
+ point.getTerminatorPredecessorOrNull()->getParentRegion()) {
+ regions.emplace_back(mlir::RegionSuccessor(op, op->getResults()));
regions.emplace_back(&op.getBody(), op.getBody().getArguments());
return;
}
// Branching from body: go to step (for) or condition.
- if (&op.getBody() == point.getRegionOrNull()) {
+ if (&op.getBody() ==
+ point.getTerminatorPredecessorOrNull()->getParentRegion()) {
// FIXME(cir): Should we consider break/continue statements here?
mlir::Region *afterBody =
(op.maybeGetStep() ? op.maybeGetStep() : &op.getCond());
@@ -42,7 +44,8 @@ void LoopOpInterface::getLoopOpSuccessorRegions(
}
// Branching from step: go to condition.
- if (op.maybeGetStep() == point.getRegionOrNull()) {
+ if (op.maybeGetStep() ==
+ point.getTerminatorPredecessorOrNull()->getParentRegion()) {
regions.emplace_back(&op.getCond(), op.getCond().getArguments());
return;
}
|
joker-eph
reviewed
Oct 28, 2025
joker-eph
reviewed
Oct 28, 2025
joker-eph
reviewed
Oct 28, 2025
joker-eph
reviewed
Oct 28, 2025
|
Thank you for reviewing. I addressed all comments @joker-eph |
joker-eph
approved these changes
Oct 28, 2025
aokblast
pushed a commit
to aokblast/llvm-project
that referenced
this pull request
Oct 30, 2025
…#165441) Fix building ClangIR after RegionBranchOpInterface revamp (llvm#165429)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix building ClangIR after RegionBranchOpInterface revamp (#165429)