[PATCH] D150340: [SEH]:Fix assertion when try is used inside catch(...) block with /EHa

Jennifer Yu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 10 19:56:09 PDT 2023


jyu2 created this revision.
jyu2 added reviewers: asmith, efriedma, tentzen, pengfei.
jyu2 added a project: clang.
Herald added subscribers: kbarton, nemanjai.
Herald added a project: All.
jyu2 requested review of this revision.

Current assert wiht /EHa with
A single unwind edge may only enter one EH pad

  invoke void @llvm.seh.try.begin()
          to label %invoke.cont1 unwind label %catch.dispatch2

IR:
%1 = catchpad within %0 [ptr null, i32 0, ptr null]

  invoke void @llvm.seh.try.begin()
          to label %invoke.cont5 unwind label %catch.dispatch2

The problem is the invoke to llvm.seh.try.begin() missing "funclet"

Accodring: https://llvm.org/docs/LangRef.html#ob-funclet
If any "funclet" EH pads have been entered but not exited (per the
description in the EH doc), it is undefined behavior to execute a
call or invoke.

To fix the problem, when emit seh_try_begin,  call EmitSehScope,
instead of calling EmitRuntimeCallOrInvoke for proper "funclet"
gerenration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150340

Files:
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150340.521199.patch
Type: text/x-patch
Size: 5526 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230511/9ffe8e32/attachment.bin>


More information about the cfe-commits mailing list