This is an archive of the discontinued LLVM Phabricator instance.

[x32] Use ebp/esp as frame and stack pointer
ClosedPublic

Authored by pavel.v.chupin on Jul 22 2014, 6:20 AM.

Details

Summary

Since pointers are 32-bit on x32 we can use ebp and esp as frame and stack
pointer. Some operations like PUSH/POP and CFI_INSTRUCTION still
require 64-bit register, so using 64-bit MachineFramePtr where required.

Diff Detail

Repository
rL LLVM

Event Timeline

pavel.v.chupin retitled this revision from to [x32] Use ebp/esp as frame and stack pointer.
pavel.v.chupin updated this object.
pavel.v.chupin edited the test plan for this revision. (Show Details)
pavel.v.chupin added reviewers: nadav, dschuff.
pavel.v.chupin added subscribers: zinovy.nis, Unknown Object (MLST).
dschuff edited edge metadata.Jul 23 2014, 5:31 PM

This area is actually one place where NaCl's 64-bit ABI differs from X32; i.e. NaCl considers the frame and stack pointers as 64 bits, but has special sequences to update them. For the purposes of this patch, instead of just e.g. using isLP64 everywhere in emitPrologue, could we just make the const at the top of be something like Uses64BitFramePtr and have that be the condition?

Splitting into FramePtr vs MachineFramePtr is fine.

pavel.v.chupin edited edge metadata.

Changed local vars names according last comments.
Updated test by adding nacl target case.

Also marked hasReservedSpillSlot as unreachable on X86.

Hi Derek,
Can you please take a look at updated version?

Hi Pavel,
Sorry about the delay, we had a bit of a disruption.
I'll get you something more detailed soon but the short version is that I found that X86Subtarget::isTarget64BitLP64() returns true for NaCl when it should return false. So I was thinking about fixing that in a separate change, which would mean this change would be slightly different. does that seem reasonable?

lib/Target/X86/X86FrameLowering.cpp
453 ↗(On Diff #11982)

It looks like X86Subtarget::IsTarget64BitLP64 returns true for NaCl when it should return false. Would you mind fixing that, and then Uses64BitFramePtr would be STI.isTarget64BitLP64() || STI.isTargetNaCl64()

OK, after taking a closer look, I had thought some other changes might be required but because of what we have upstream and downstream, we'll have to fix stuff on our end anyway. For the purposes of this change, can you change X86Subtarget::isTarget64BitLP64() to return false for NaCl (and then Uses64BitFramePtr would be STI.isTarget64BitLP64() || STI.isTargetNaCl64()), and then LGTM

Thanks. I made corresponding changes.

pavel.v.chupin closed this revision.Aug 7 2014, 2:50 AM
pavel.v.chupin updated this revision to Diff 12274.

Closed by commit rL215091 (authored by pvchupin).