[all-commits] [llvm/llvm-project] ebc2f7: [CIR] Fix lost catch clauses on EH landing pads (#...

adams381 via All-commits all-commits at lists.llvm.org
Thu Jun 25 10:56:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ebc2f7946ad76daa1c4db18fc9196d94845e6946
      https://github.com/llvm/llvm-project/commit/ebc2f7946ad76daa1c4db18fc9196d94845e6946
  Author: adams381 <adams at nvidia.com>
  Date:   2026-06-25 (Thu, 25 Jun 2026)

  Changed paths:
    M clang/lib/CIR/Dialect/Transforms/EHABILowering.cpp
    A clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp

  Log Message:
  -----------
  [CIR] Fix lost catch clauses on EH landing pads (#205638)

A throw caught by an enclosing handler could call std::terminate instead of
entering the handler. The smallest trigger is a try that destroys a local and
throws a new-expression whose type has a throwing constructor: two cleanups
then sit on the path to the handler and produce two cir.eh.initiate operations
that funnel into one cir.eh.dispatch. The same bug also asserted on ordinary
nested try/catch and dropped the outer handler's catch clause from the inner
landing pad on a nested throw.

ItaniumEHLowering::lowerEhInitiate derived each landing pad's catch clauses
while destructively walking the eh_token graph, tying a correctness property
to lowering order: whichever initiate lowered first tore down the shared cir.br
edges, so the other reached no dispatch and kept an empty catch_type_list -- a
cleanup-only landing pad that resumes past the handler.

lowerFunc now does a read-only walk first. For each initiate it collects every
dispatch the exception can reach (innermost first, preserving nested catch
order) and records the catch_type_list, plus the cleanup clause when a cleanup
lies on the unwind path. Each dispatch is lowered once, after every initiate has
been processed.

Follow-up to #199121, which added cleanup-scope throw handling for the
single-dispatch case.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list