[llvm] r201904 - [Stackmaps] Move the target-independent frame index elimination for stackmaps and patchpoints into target-specific code.

Philip Reames listmail at philipreames.com
Tue Feb 25 17:35:11 PST 2014


I will try to prepare my hacks for upstreaming.  I'm probably going to 
start sending patches for a couple of issues either this week or next.  
This will be somewhere in the middle of the sequence; I'm trying to 
start with the simple standalone stuff first.

Philip

On 02/24/2014 03:33 PM, Juergen Ributzka wrote:
> Hi Philip,
>
> that is true. Currently we assume and also expect that all references are made relative to the FP. Given a certain set of constrains on the IR this assumption is valid for X86-64 (e.g. no vector register spills). It would be great if you could add an option to choose the preferred base register, so nobody is forced to use the FP as base register in their runtime code. We already designed the stack map format with this flexibility in mind, which can encode any register + offset pair.
>
> Cheers,
> Juergen
>
> On Feb 24, 2014, at 3:12 PM, Philip Reames <listmail at philipreames.com> wrote:
>
>> Juergen,
>>
>> Just to note, I have an out of tree extension to patchpoint which relies on being able to use RSP rather than RBP as the base for the stack references.  Adapting our code to handle your change won't be difficult, I just wanted to point it out since you seem to be running with the assumption that will never be the case.
>>
>> At some point, it would make sense for me to upstream an option to choose between RBP and RSP relative offsets.  Different runtimes will have different assumptions.  I'll have to clean up my horribly hacky code before I can do that though.  :)
>>
>> Philip
>>
>>
>> On 02/21/2014 03:29 PM, Juergen Ributzka wrote:
>>> Author: ributzka
>>> Date: Fri Feb 21 17:29:32 2014
>>> New Revision: 201904
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=201904&view=rev
>>> Log:
>>> [Stackmaps] Move the target-independent frame index elimination for stackmaps and patchpoints into target-specific code.
>>>
>>> The lowering of the frame index for stackmaps and patchpoints requires some
>>> target-specific magic and should therefore be handled in the target-specific
>>> eliminateFrameIndex method.
>>>
>>> This is related to <rdar://problem/16106219>
>>>
>>> Modified:
>>>      llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
>>>      llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
>>>
>>> Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=201904&r1=201903&r2=201904&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
>>> +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Feb 21 17:29:32 2014
>>> @@ -779,18 +779,15 @@ void PEI::replaceFrameIndices(MachineBas
>>>         // Frame indicies in debug values are encoded in a target independent
>>>         // way with simply the frame index and offset rather than any
>>>         // target-specific addressing mode.
>>> -      if (MI->isDebugValue() ||
>>> -          MI->getOpcode() == TargetOpcode::STACKMAP ||
>>> -          MI->getOpcode() == TargetOpcode::PATCHPOINT) {
>>> -        assert((!MI->isDebugValue() || i == 0) &&
>>> -               "Frame indicies can only appear as the first operand of a "
>>> -               "DBG_VALUE machine instruction");
>>> +      if (MI->isDebugValue()) {
>>> +        assert(i == 0 && "Frame indicies can only appear as the first "
>>> +                         "operand of a DBG_VALUE machine instruction");
>>>           unsigned Reg;
>>> -        MachineOperand &Offset = MI->getOperand(i + 1);
>>> +        MachineOperand &Offset = MI->getOperand(1);
>>>           Offset.setImm(Offset.getImm() +
>>>                         TFI->getFrameIndexReference(
>>> -                          Fn, MI->getOperand(i).getIndex(), Reg));
>>> -        MI->getOperand(i).ChangeToRegister(Reg, false /*isDef*/);
>>> +                          Fn, MI->getOperand(0).getIndex(), Reg));
>>> +        MI->getOperand(0).ChangeToRegister(Reg, false /*isDef*/);
>>>           continue;
>>>         }
>>>   
>>> Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=201904&r1=201903&r2=201904&view=diff
>>> ==============================================================================
>>> --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
>>> +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Fri Feb 21 17:29:32 2014
>>> @@ -516,6 +516,15 @@ X86RegisterInfo::eliminateFrameIndex(Mac
>>>     } else
>>>       FIOffset = TFI->getFrameIndexOffset(MF, FrameIndex);
>>>   +  // The frame index format for stackmaps and patchpoints is different from the
>>> +  // X86 format. It only has a FI and an offset.
>>> +  if (Opc == TargetOpcode::STACKMAP || Opc == TargetOpcode::PATCHPOINT) {
>>> +    assert(BasePtr == FramePtr && "Expected the FP as base register");
>>> +    int64_t Offset = MI.getOperand(FIOperandNum + 1).getImm() + FIOffset;
>>> +    MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
>>> +    return;
>>> +  }
>>> +
>>>     if (MI.getOperand(FIOperandNum+3).isImm()) {
>>>       // Offset is a 32-bit integer.
>>>       int Imm = (int)(MI.getOperand(FIOperandNum + 3).getImm());
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list