This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Always use MSVC personality for windows-msvc targets
ClosedPublic

Authored by smeenai on Jun 6 2018, 7:10 PM.

Details

Summary

The windows-msvc target is meant to be ABI compatible with MSVC,
including the exception handling. Ensure that a windows-msvc triple
always equates to the MSVC personality being used.

This mostly affects the GNUStep and ObjFW Obj-C runtimes. To the best of
my knowledge, those are normally not used with windows-msvc triples. I
believe WinObjC is based on GNUStep (or it at least uses libobjc2), but
that also takes the approach of wrapping Obj-C exceptions in C++
exceptions, so the MSVC personality function is the right one to use
there as well.

Diff Detail

Repository
rC Clang

Event Timeline

smeenai created this revision.Jun 6 2018, 7:10 PM
rnk added inline comments.Jun 7 2018, 3:43 PM
lib/CodeGen/CGException.cpp
134–135

I guess previously we carefully arranged to go to whatever the regular objc personality would be, but we're not doing that now with funclet windows eh.
Maybe we could drastically simplify this by checking for an msvc environment and seh before checking each language?

smeenai added inline comments.Jun 7 2018, 5:17 PM
lib/CodeGen/CGException.cpp
134–135

I gave this a shot. EHPersonality::get already has code to make SEH functions always get the SEH personality (line 223 below), so I added another condition below to make an MSVC triple always get the MSVC personality, and then removed all those conditionals from the individual get*Personality functions. Unfortunately, there's also code below (in SimplifyPersonality) that calls getCXXPersonality directly, so we still need to leave the MSVC check in there, and having the check in there but not any of the other get*Personality functions seems really ugly. The other option is to adjust SimplifyPersonality instead, which ends up looking like P8086; do you think that's worth it? Or did you mean something else entirely?

rnk accepted this revision.Jun 7 2018, 5:22 PM
rnk added inline comments.
lib/CodeGen/CGException.cpp
134–135

That's what I meant, but I see how it ends up inconsistent. Let's go with this.

This revision is now accepted and ready to land.Jun 7 2018, 5:22 PM
This revision was automatically updated to reflect the committed changes.