When a for, while, or do/while loop contains a break or continue statement at the top level of the loop's body and the last statement of the block, that triggers an assertion failure during ClangIR lowering to LLVM dialect.
void test(int x) {
for (int i = 0; i < x; ++i) {
--x;
break;
}
}
clang: .../mlir/lib/Transforms/Utils/DialectConversion.cpp:1372:
void mlir::detail::ConversionPatternRewriterImpl::notifyOpReplaced(mlir::Operation*, mlir::ValueRange):
Assertion `!replacements.count(op) && "operation was already replaced"' failed.
If the break or continue is in a nested scope within the loop (which is the normal case in real code), there is no error. If the break or continue statement is not the last statement in the block then there is a different internal error which is covered by #323.