This is an archive of the discontinued LLVM Phabricator instance.

Add a Windows EH preparation pass that zaps resumes
ClosedPublic

Authored by rnk on Jan 27 2015, 5:52 PM.

Details

Summary

If the personality is not a recognized MSVC personality function, this
pass delegates to the dwarf EH preparation pass. This chaining supports
people on *-windows-itanium or *-windows-gnu targets.

Currently this recognizes some personalities used by MSVC and turns
resume instructions into traps to avoid link errors. Even if cleanups
are not used in the source program, LLVM requires the frontend to emit a
code path that resumes unwinding after an exception. Clang does this,
and we get unreachable resume instructions. PR20300 covers cleaning up
these unreachable calls to resume.

Diff Detail

Event Timeline

rnk updated this revision to Diff 18870.Jan 27 2015, 5:52 PM
rnk retitled this revision from to Add a Windows EH preparation pass that zaps resumes.
rnk updated this object.
rnk added a reviewer: majnemer.
rnk added a subscriber: Unknown Object (MLST).
majnemer edited edge metadata.Jan 27 2015, 7:24 PM

I don't see an IR->IR test, could we have one for this transform?

lib/CodeGen/WinEHPrepare.cpp
29–30
79

LPads.back() perhaps?

I bet you intended on using this LPads vector in the future, right now it seems pretty useless though.

93–94

Why do you create a call to @llvm.trap and an unreachable instruction?

102

Does it make sense to do this unconditionally, even if the function has MSVC personality?

106

Does it make sense to do this unconditionally, even if the function has MSVC personality?

rnk added a comment.Jan 28 2015, 4:33 PM

Seems like the IR to IR test worked... I'm surprised TargetMachine isn't null, causing DwarfEHPrepare crashes... but I'll take what I can get.

lib/CodeGen/WinEHPrepare.cpp
29–30

True, thanks. This was cribbed from DwarfEHPrepare.

79

Sure. I am collecting the landing pads for future use.

93–94

unreachable is typically not ud2a, but literally "nothing" on non-windows platforms, but I guess unreachable is fine on Windows. We'll get one ud2a.

102

Yes, this is whole module finalization, so some functions could be MSVC and some could be GCC.

106

ditto

rnk updated this revision to Diff 18928.Jan 28 2015, 4:35 PM
rnk edited edge metadata.
  • Add IR to IR test
majnemer accepted this revision.Jan 28 2015, 4:39 PM
majnemer edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Jan 28 2015, 4:39 PM
This revision was automatically updated to reflect the committed changes.