Page MenuHomePhabricator

[X86] Make sure we do not clobber RBX with mwaitx when used as a base pointer.
Needs ReviewPublic

Authored by pgousseau on Jan 27 2020, 7:15 AM.

Details

Summary

mwaitx uses EBX as one of its argument.
Using this instruction clobbers RBX as it is defined to hold one of the input. When the backend uses dynamically allocated stack, RBX is used as a reserved register for the base pointer.

This patch is adapted from @qcolombet patch for cmpxchg at r263325.

This fixes PR43528.

Diff Detail

Event Timeline

pgousseau created this revision.Jan 27 2020, 7:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2020, 7:15 AM

Is this subject to the same problem as PR42064?

Is this subject to the same problem as PR42064?

Thanks for pointing this issue, yes I believe this change will have the same problem in cases where stack realignment occurs after mwaitx pseudo instruction is generated.
If I understand the conclusion of the PR is that the decision to save/restore base pointer needs to be done after PEI? I will try that approach.