Skip to content

Commit e290bc0

Browse files
committed
[CIR][FlattenCFG] Exceptions: move cir.eh.selector up to dominate more uses
1 parent 5c067d1 commit e290bc0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ class CIRTryOpFlattening : public mlir::OpRewritePattern<mlir::cir::TryOp> {
234234
rewriter.setInsertionPointToEnd(catchBegin);
235235
auto exception = rewriter.create<mlir::cir::EhInflightOp>(
236236
loc, mlir::cir::ExceptionInfoType::get(rewriter.getContext()));
237+
auto selector = rewriter.create<mlir::cir::EhSelectorOp>(loc, exception);
237238

238239
// TODO: direct catch all needs no dispatch?
239240

@@ -247,7 +248,6 @@ class CIRTryOpFlattening : public mlir::OpRewritePattern<mlir::cir::TryOp> {
247248

248249
// Fill in dispatcher.
249250
rewriter.setInsertionPointToEnd(dispatchBlock);
250-
auto selector = rewriter.create<mlir::cir::EhSelectorOp>(loc, exception);
251251

252252
// FIXME: we should have an extra block for the dispatcher, just in case
253253
// there isn't one later.

clang/test/CIR/Lowering/try-catch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ unsigned long long tc() {
2626

2727
// CIR_FLAT: ^[[LPAD]]: // pred: ^bb2
2828
// CIR_FLAT: %[[EH:.*]] = cir.eh.inflight_exception
29+
// CIR_FLAT: %[[SEL:.*]] = cir.eh.selector %[[EH]]
2930
// CIR_FLAT: cir.br ^[[BB_INT_IDX_SEL:.*]] loc
3031
// CIR_FLAT: ^[[BB_INT_IDX_SEL]]: // pred: ^[[LPAD]]
31-
// CIR_FLAT: %[[SEL:.*]] = cir.eh.selector %[[EH]]
3232
} catch (int idx) {
3333
// CIR_FLAT: %[[INT_IDX_ID:.*]] = cir.eh.typeid @_ZTIi
3434
// CIR_FLAT: %[[MATCH_CASE_INT_IDX:.*]] = cir.cmp(eq, %[[SEL]], %[[INT_IDX_ID]]) : !u32i, !cir.bool

0 commit comments

Comments
 (0)