[PATCH] D127545: Remove Itanium EH ABI workaround to allow modifying a pointer caught by-reference.

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 15:36:51 PDT 2022


jyknight created this revision.
jyknight added reviewers: rjmccall, nikic.
Herald added a project: All.
jyknight requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Pointers will now always be caught by-value.

The workaround was originally added in commit
5add20cefac7d1b06e7892ce0d97767a23db4e1a. (Note, that commit also made
the codegen for catching a pointer by reference work _at all_. I am
not reverting that part of it.)

The intent was to enable `catch (int*&ptr) { ptr = 0; throw; }`
to correctly propagate the new value of ptr to a higher catch block.

Unfortunately, the implementation was always rather suspect, as it
hardcoded byte offsets of EH structs, and accessed data directly,
assuming it knew the layout. Unfortunately, as recently reported, this
is now known to break std::rethrow_exception, as that doesn't use the
expected layout.

Because it does not appear possible to solve the issue in a principled
way without modifying the Itanium ABI, this change simply removes the
hack.

While we therefore fix the bug referenced, this also introduces the
bug whereby modifying a pointer caught by reference is no longer
visible to other catch blocks.

Introduces FIXME file new bug and link here FIXME
Fixes https://github.com/llvm/llvm-project/issues/55340


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127545

Files:
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGenCXX/eh.cpp
  clang/test/CodeGenCXX/sizeof-unwind-exception.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127545.436061.patch
Type: text/x-patch
Size: 10200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220610/a95a4563/attachment.bin>


More information about the cfe-commits mailing list