This is an archive of the discontinued LLVM Phabricator instance.

StackProtector: insert check before `musttail` call.
ClosedPublic

Authored by t.p.northover on Mar 16 2021, 6:00 AM.

Details

Reviewers
compnerd
aemerson
Summary

musttail calls have to directly precede the return instruction (of their value), so any stack checks must be inserted before the call instead of in between it and the return. Fortunately this same restriction means we don't have to look too hard to find out if we're about to break a musttail call.

Diff Detail

Unit TestsFailed

Event Timeline

t.p.northover created this revision.Mar 16 2021, 6:00 AM
t.p.northover requested review of this revision.Mar 16 2021, 6:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2021, 6:00 AM
t.p.northover planned changes to this revision.Mar 16 2021, 9:07 AM

We've just discovered there are problems on the SDAG path too for guaranteed tail calls. I'll update the patch once I've got a fix ready.

Fixed the issue in SelectionDAG too. Not quite identical there, but still fundamentally hinged on exactly where the check should be placed.

aemerson accepted this revision.Mar 26 2021, 4:03 PM

LGTM with comment nit.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
1713 ↗(On Diff #331239)

An example of what code you're looking for in this comment would be helpful.

This revision is now accepted and ready to land.Mar 26 2021, 4:03 PM
t.p.northover closed this revision.Apr 13 2021, 7:15 AM

Thanks Amara. Committed with a beefed up comment as 5e3d9fcc3a88.