This is an archive of the discontinued LLVM Phabricator instance.

[SEH] Add new intrinsics for recovering and restoring parent frames
ClosedPublic

Authored by rnk on Jun 30 2015, 1:36 PM.

Details

Summary

The incoming EBP value established by the runtime is actually a pointer
to the end of the EH registration object, and not the true parent
function frame pointer. Clang doesn't need llvm.x86.seh.exceptioninfo
anymore because we know that the exception info pointer is at a fixed
offset from this incoming EBP.

The llvm.x86.seh.recoverfp intrinsic takes an EBP value provided by the
EH runtime and returns a pointer that is usable with llvm.framerecover.

The llvm.x86.seh.restoreframe intrinsic is inserted by the 32-bit
specific preparation pass in blocks targetted by the EH runtime. It
re-establishes any physical registers used by the parent function to
address the stack, such as the frame, base, and stack pointers.

Neither of these intrinsics correctly handle stack realignment prologues
yet, but it's possible to add that later.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk updated this revision to Diff 28810.Jun 30 2015, 1:36 PM
rnk retitled this revision from to [SEH] Add new intrinsics for recovering and restoring parent frames.
rnk updated this object.
rnk added a reviewer: majnemer.
rnk added a subscriber: Unknown Object (MLST).
majnemer added inline comments.Jun 30 2015, 2:35 PM
lib/Target/X86/X86ISelLowering.cpp
15012–15014 ↗(On Diff #28810)

Please make this comment match the code.

rnk updated this revision to Diff 28818.Jun 30 2015, 3:17 PM
  • Move frame pointer recovery math closer to the intrinsic lowering
majnemer accepted this revision.Jun 30 2015, 3:31 PM
majnemer edited edge metadata.

LGTM with comments addressed.

lib/Target/X86/X86ISelLowering.cpp
15019 ↗(On Diff #28818)

Maybe make this a fatal error.

15486–15491 ↗(On Diff #28818)

Does somebody need to make sure the argument is pointing at a function? (verifer or backend fatal error or somesuch).

15704 ↗(On Diff #28818)

Dead code?

This revision is now accepted and ready to land.Jun 30 2015, 3:31 PM
This revision was automatically updated to reflect the committed changes.