Page MenuHomePhabricator

Add a Windows EH preparation pass that zaps resumes

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



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?

28–29 ↗(On Diff #18870)
78 ↗(On Diff #18870)

LPads.back() perhaps?

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

92–93 ↗(On Diff #18870)

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

101 ↗(On Diff #18870)

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

105 ↗(On Diff #18870)

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.

28–29 ↗(On Diff #18870)

True, thanks. This was cribbed from DwarfEHPrepare.

78 ↗(On Diff #18870)

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

92–93 ↗(On Diff #18870)

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.

101 ↗(On Diff #18870)

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

105 ↗(On Diff #18870)


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.


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.