This is an archive of the discontinued LLVM Phabricator instance.

Remove Itanium EH ABI workaround to allow modifying a pointer caught by-reference.
Needs ReviewPublic

Authored by jyknight on Jun 10 2022, 3:36 PM.

Details

Reviewers
rjmccall
nikic
Summary

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

Diff Detail

Event Timeline

jyknight created this revision.Jun 10 2022, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 3:36 PM
jyknight requested review of this revision.Jun 10 2022, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 3:36 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

(Note: if folks agree with this direction, I'll file a new bug for the newly broken behavior -- even though we probably cannot actually fix it -- and link it from the commit.)

Should we just diagnose this and report an error that catching pointers by non-const reference is unsupported on Itanium? We don't support it properly for class pointers anyway.

clang/test/CodeGenCXX/eh.cpp