================
@@ -397,17 +474,40 @@ mlir::LogicalResult
ItaniumEHLowering::lowerFunc(cir::FuncOp funcOp) {
/// \p ehTokenMap is shared across all initiates in the function so that block
/// arguments reachable from multiple sibling initiates are registered once.
mlir::LogicalResult ItaniumEHLowering::lowerEhInitiate(
- cir::EhInitiateOp initiateOp, EhTokenMap &ehTokenMap,
- SmallVectorImpl<mlir::Operation *> &deadOps) {
+ cir::EhInitiateOp initiateOp,
+ llvm::ArrayRef<cir::EhDispatchOp> reachedDispatches, bool reachesCleanup,
+ EhTokenMap &ehTokenMap, SmallVectorImpl<mlir::Operation *> &deadOps) {
mlir::Value rootToken = initiateOp.getEhToken();
- // Create the inflight_exception without a catch_type_list. The catch types
- // will be set once we encounter the dispatch during the traversal below.
+ // The catch clauses for this landing pad come from the dispatches its
+ // exception reaches (computed read-only by the caller before any destructive
+ // lowering). For nested try/catch the exception can reach several
dispatches
+ // innermost first, so the landing pad lists their catch types in that order
+ // (matching classic CodeGen), stopping at a catch-all since nothing escapes
+ // it. Deriving this from the original EH graph -- rather than during the
+ // destructive token-graph traversal below -- keeps it correct regardless of
+ // the order in which sibling/nested initiates are lowered.
+ mlir::ArrayAttr catchTypeList;
+ bool catchAll = false;
+ SmallVector<mlir::Attribute> typeSymbols;
+ for (cir::EhDispatchOp dispatch : reachedDispatches) {
+ if (mlir::ArrayAttr catchTypes = dispatch.getCatchTypesAttr())
+ for (mlir::Attribute attr : catchTypes)
+ typeSymbols.push_back(
+ mlir::cast<cir::GlobalViewAttr>(attr).getSymbol());
+ if (dispatch.getDefaultIsCatchAll()) {
+ catchAll = true;
+ break;
----------------
andykaylor wrote:
A comment here explaining why you don't want to process remaining dispatches
would be helpful. I think you could also assert that there are no more
dispatches to process.
https://github.com/llvm/llvm-project/pull/205638
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits