[LLVMdev] Question about callee saved registers in x86

Sanjoy Das sanjoy at azulsystems.com
Tue May 27 16:57:05 PDT 2014


Hi llvmdev,

I'm trying to figure how llvm remembers stack slots allotted to callee
saved registers on x86.  In particular, llvm pushes registers in
decreasing order of FrameIdxs [1], so the offsets they get (as
returned by MFI->getObjectOffset) don't directly correspond to their
actual stack locations.  In X86FrameLowering's
emitCalleeSavedFrameMoves, when emitting DWARF information, this
discrepancy gets fixed up by subtracting the offset reported by
MFI->getObjectOffset from the minimum offset for any CSR (this is done
by the "Offset = MaxOffset - Offset + saveAreaOffset;" line).  Is
there a reason why llvm doesn't keep around the offsets in the right
order from very beginning, by pushing the CSRs in increasing order of
FrameIdxs?

[1]: in fact, the way X86FrameLowering's spillCalleeSavedRegisters and
PEI's calculateCalleeSavedRegisters are set up, I don't see a reason
why the FrameIdxs and the generated push instructions have any
relation at all.  It seems that the code relies on
MFI->CreateStackObject returning sequential integers.

Thanks!
-- Sanjoy




More information about the llvm-dev mailing list