This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Make __clang_call_terminate have an unwind table entry
ClosedPublic

Authored by smeenai on May 24 2023, 6:37 PM.

Details

Summary

This enables unwinders to step past that frame on architectures that
don't use DWARF unwinding (such as armv7), e.g. when debugging. The
problem should theoretically be architecture-agnostic, but according to
https://discourse.llvm.org/t/51633/2 it gets masked on architectures
that use DWARF unwind info.

Fixes https://github.com/llvm/llvm-project/issues/40696

Diff Detail

Event Timeline

smeenai created this revision.May 24 2023, 6:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 6:37 PM
smeenai requested review of this revision.May 24 2023, 6:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2023, 6:37 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
smeenai edited the summary of this revision. (Show Details)May 24 2023, 6:45 PM
efriedma added inline comments.May 24 2023, 8:38 PM
clang/lib/CodeGen/ItaniumCXXABI.cpp
4699

We probably want to call SetLLVMFunctionAttributesForDefinition() here instead. The end result isn't that much different, but it indicates the intent more clearly, and hopefully we avoid hitting similar issues in this code in the future.

smeenai updated this revision to Diff 525429.May 24 2023, 8:55 PM

Call SetLLVMFunctionAttributesForDefinition instead

smeenai marked an inline comment as done.May 24 2023, 8:55 PM
rnk accepted this revision.May 25 2023, 10:24 AM

Makes sense to me too, but wait for approval by @efriedma

This revision is now accepted and ready to land.May 25 2023, 10:24 AM

LGTM. Is there an existing test that can merge in the uwtable test?

I searched for __clang_call_terminate in the Clang test directory when I was working on this diff. Most tests were testing calls to it, not definitions. There were a couple of tests checking the definition, but they seemed pretty targeted (e.g. https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenCXX/noexcept.cpp) or auto-generated, so I figured having a separate test case for the specific thing I cared about was best.

I searched for __clang_call_terminate in the Clang test directory when I was working on this diff. Most tests were testing calls to it, not definitions. There were a couple of tests checking the definition, but they seemed pretty targeted (e.g. https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGenCXX/noexcept.cpp) or auto-generated, so I figured having a separate test case for the specific thing I cared about was best.

Thank you for the research!