[llvm-dev] Statepoints with non SP-relative addresses

Oscar Blumberg via llvm-dev llvm-dev at lists.llvm.org
Tue Jun 7 06:08:52 PDT 2016


Hi all,

Is there a particular reason for statepoints to only reference stack
memory relatively to the stack pointer ?

This came up in the following configuration :
- the frame lowering decides that !hasReservedCallFrame
- the call has a static alloca in the deopt bundle
- the call has enough arguments to require spilling some to the stack
In that case the stackmap will contain an entry that ignores the
adjustments to SP made by the lowering around the call and does not
point to the right address.
Even though this looks like a bug and could probably be fixed, the
following simple patch seem to be enough as it lets the target pick
the register. As far as I can tell it correctly uses BP when
necessary.

> diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp
> index be3e5e2..6064e6f 100644
> --- a/lib/CodeGen/PrologEpilogInserter.cpp
> +++ b/lib/CodeGen/PrologEpilogInserter.cpp
> @@ -1094,7 +1094,7 @@ void PEI::replaceFrameIndices(MachineBasicBlock *BB, MachineFunction &Fn,
>          unsigned Reg;
>          MachineOperand &Offset = MI->getOperand(i + 1);
>          const unsigned refOffset =
> -          TFI->getFrameIndexReferenceFromSP(Fn, MI->getOperand(i).getIndex(),
> +          TFI->getFrameIndexReference(Fn, MI->getOperand(i).getIndex(),
>                                              Reg);
>
>          Offset.setImm(Offset.getImm() + refOffset);

I'm also wondering if there is any guarantee that this would work in
all the possible call frame configurations (variable length alloca,
stack realignment, ...).

Thanks !
Oscar


More information about the llvm-dev mailing list