-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir] Simplify unreachable type switch cases. NFC. #162032
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
Conversation
Use `DefaultUnreachable` from llvm#161970.
@llvm/pr-subscribers-mlir-scf @llvm/pr-subscribers-mlir-linalg Author: Jakub Kuderski (kuhar) ChangesUse Full diff: https://github.com/llvm/llvm-project/pull/162032.diff 7 Files Affected:
diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
index d57926ec5a1ca..39d4815dc73b7 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp
@@ -243,7 +243,7 @@ static void getTreePredicates(std::vector<PositionalPredicate> &predList,
.Case<OperandPosition, OperandGroupPosition>([&](auto *pos) {
getOperandTreePredicates(predList, val, builder, inputs, pos);
})
- .Default([](auto *) { llvm_unreachable("unexpected position kind"); });
+ .DefaultUnreachable("unexpected position kind");
}
static void getAttributePredicates(pdl::AttributeOp op,
diff --git a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
index 9196d2ef79592..39e398b8ae6ae 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
@@ -170,7 +170,7 @@ class OuterProductFusion2Way
op2, op.getResultType(), lhs, rhs, lhsMask, rhsMask,
op1.getAcc());
})
- .Default([&](auto) { llvm_unreachable("unexpected extend op!"); });
+ .DefaultUnreachable("unexpected extend op!");
} else if (kind == arm_sme::CombiningKind::Sub) {
TypeSwitch<Operation *>(extOp)
.Case<arith::ExtFOp>([&](auto) {
@@ -188,7 +188,7 @@ class OuterProductFusion2Way
op2, op.getResultType(), lhs, rhs, lhsMask, rhsMask,
op1.getAcc());
})
- .Default([&](auto) { llvm_unreachable("unexpected extend op!"); });
+ .DefaultUnreachable("unexpected extend op!");
} else {
llvm_unreachable("unexpected arm_sme::CombiningKind!");
}
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index c0f9132de3db4..19eba6beacd86 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -375,7 +375,7 @@ void GPUDialect::printType(Type type, DialectAsmPrinter &os) const {
os << shape.back() << 'x' << fragTy.getElementType();
os << ", \"" << fragTy.getOperand() << "\"" << '>';
})
- .Default([](Type) { llvm_unreachable("unexpected 'gpu' type kind"); });
+ .DefaultUnreachable("unexpected 'gpu' type kind");
}
static LogicalResult verifyKnownLaunchSizeAttr(Operation *op,
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index 38f1a8b7247eb..42160a15bc755 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -192,7 +192,7 @@ static void replaceIndexOpsByInductionVariables(RewriterBase &rewriter,
.Case([&](affine::AffineForOp affineForOp) {
allIvs.push_back(affineForOp.getInductionVar());
})
- .Default([&](Operation *op) { assert(false && "unexpected op"); });
+ .DefaultUnreachable("unexpected op");
}
assert(linalgOp.getNumLoops() == allIvs.size() &&
"expected the number of loops and induction variables to match");
diff --git a/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp b/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
index 24da447ad7685..214410f78e51c 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
+++ b/mlir/lib/Dialect/MemRef/Transforms/FoldMemRefAliasOps.cpp
@@ -315,7 +315,7 @@ LogicalResult LoadOpOfSubViewOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), subViewOp.getSource(), sourceIndices,
op.getTranspose(), op.getNumTiles());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
@@ -367,7 +367,7 @@ LogicalResult LoadOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), expandShapeOp.getViewSource(), sourceIndices,
op.getMask(), op.getPassThru());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
@@ -415,7 +415,7 @@ LogicalResult LoadOpOfCollapseShapeOpFolder<OpTy>::matchAndRewrite(
op, op.getType(), collapseShapeOp.getViewSource(), sourceIndices,
op.getMask(), op.getPassThru());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
@@ -482,7 +482,7 @@ LogicalResult StoreOpOfSubViewOpFolder<OpTy>::matchAndRewrite(
op, op.getSrc(), subViewOp.getSource(), sourceIndices,
op.getLeadDimension(), op.getTransposeAttr());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
@@ -535,7 +535,7 @@ LogicalResult StoreOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite(
op, expandShapeOp.getViewSource(), sourceIndices, op.getMask(),
op.getValueToStore());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
@@ -584,7 +584,7 @@ LogicalResult StoreOpOfCollapseShapeOpFolder<OpTy>::matchAndRewrite(
op, collapseShapeOp.getViewSource(), sourceIndices, op.getMask(),
op.getValueToStore());
})
- .Default([](Operation *) { llvm_unreachable("unexpected operation."); });
+ .DefaultUnreachable("unexpected operation");
return success();
}
diff --git a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
index e2c987ae1b37f..f49d3d048a579 100644
--- a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
+++ b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp
@@ -154,7 +154,7 @@ void NodePrinter::print(Type type) {
})
.Case([&](TypeType) { os << "Type"; })
.Case([&](ValueType) { os << "Value"; })
- .Default([](Type) { llvm_unreachable("unknown AST type"); });
+ .DefaultUnreachable("unknown AST type");
}
void NodePrinter::print(const Node *node) {
@@ -182,7 +182,7 @@ void NodePrinter::print(const Node *node) {
const VariableDecl,
const Module>([&](auto derivedNode) { this->printImpl(derivedNode); })
- .Default([](const Node *) { llvm_unreachable("unknown AST node"); });
+ .DefaultUnreachable("unknown AST node");
elementIndentStack.pop_back();
}
diff --git a/mlir/lib/Tools/PDLL/AST/Nodes.cpp b/mlir/lib/Tools/PDLL/AST/Nodes.cpp
index 159ce6235662b..5aa09375bc79d 100644
--- a/mlir/lib/Tools/PDLL/AST/Nodes.cpp
+++ b/mlir/lib/Tools/PDLL/AST/Nodes.cpp
@@ -72,7 +72,7 @@ class NodeVisitor {
const Module>(
[&](auto derivedNode) { this->visitImpl(derivedNode); })
- .Default([](const Node *) { llvm_unreachable("unknown AST node"); });
+ .DefaultUnreachable("unknown AST node");
}
private:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/85/builds/14229 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/24/builds/13370 Here is the relevant piece of the build log for the reference
|
Use
DefaultUnreachable
from #161970.