[llvm-dev] Finding caller-saved registers at a function call site

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 22 14:01:33 PDT 2016


Hi Rob,

Rob Lyerly via llvm-dev wrote:
 > I'm looking for a way to get all the caller-saved registers (both the
 > register and the stack slot at which it was saved) for a given function
 > call site in the backend.  What's the best way to grab this
 > information?  Is it possible to get this information if I have the
 > MachineInstr of the function call?  I'm currently targeting the AArch64
 > & X86 backends.

You should be able to use the RegMask operand to the MachineInstr to
discover the registers that are preserved or clobbered by the call
according to the calling convention.  For reference, you might want to
look at `getRegMask` and `gatherMaximalPreservedRegisters` in
http://reviews.llvm.org/D21115.

As far as discovering the slot to which it is spilled, I have no idea.
CC'ing Matthias for this.

-- Sanjoy


More information about the llvm-dev mailing list