Skip to content

DNM: X86: fix frame offset calculation with mandatory tail calls #3121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

aschwaighofer
Copy link

If there's a region of the stack reserved for potential tail call
arguments (only the case when we guarantee tail calls will be honoured),
this is right next to the incoming stored return address, not
necessarily next to the callee-saved area, so combining the two into a
single figure leads to incorrect offsets in some edge cases.

This keeps the two concepts split and (hopefully) updates all users of
getCalleeSavedFrameSize that need it. The notable exceptions are the
stack-realignment code in emitEpilogue (~line 2117) which is where the
bug came from, and Windows-ABI functions, because they don't guarantee
tail calls so it should always be zero there.

Similarly, the code in getFrameIndexReference that dealt with this delta
wasn't present on the realigned stack branch so I refactored it so that
wasn't possible any more.

based on https://reviews.llvm.org/D106444 with the notable change that needsStackRealignment is used instead of hasStackRealignment (which does not exist yet).

rdar://80786596

If there's a region of the stack reserved for potential tail call
arguments (only the case when we guarantee tail calls will be honoured),
this is right next to the incoming stored return address, not
necessarily next to the callee-saved area, so combining the two into a
single figure leads to incorrect offsets in some edge cases.

This keeps the two concepts split and (hopefully) updates all users of
getCalleeSavedFrameSize that need it. The notable exceptions are the
stack-realignment code in emitEpilogue (~line 2117) which is where the
bug came from, and Windows-ABI functions, because they don't guarantee
tail calls so it should always be zero there.

Similarly, the code in getFrameIndexReference that dealt with this delta
wasn't present on the realigned stack branch so I refactored it so that
wasn't possible any more.

rdar://80786596
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants