mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-19 02:42:58 +00:00
On pic function calls some arguments were marked dead and
the instruction to load those args removed. This fix PR6071 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce8febefa5
commit
9201b10daa
@ -495,10 +495,15 @@ SDNode* MipsDAGToDAGISel::Select(SDNode *Node) {
|
||||
/// be loaded with 3 instructions.
|
||||
case MipsISD::JmpLink: {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_) {
|
||||
unsigned LastOpNum = Node->getNumOperands()-1;
|
||||
|
||||
SDValue Chain = Node->getOperand(0);
|
||||
SDValue Callee = Node->getOperand(1);
|
||||
SDValue T9Reg = CurDAG->getRegister(Mips::T9, MVT::i32);
|
||||
SDValue InFlag(0, 0);
|
||||
SDValue InFlag;
|
||||
|
||||
// Skip the incomming flag if present
|
||||
if (Node->getOperand(LastOpNum).getValueType() == MVT::Flag)
|
||||
LastOpNum--;
|
||||
|
||||
if ( (isa<GlobalAddressSDNode>(Callee)) ||
|
||||
(isa<ExternalSymbolSDNode>(Callee)) )
|
||||
@ -513,18 +518,28 @@ SDNode* MipsDAGToDAGISel::Select(SDNode *Node) {
|
||||
Chain = Load.getValue(1);
|
||||
|
||||
// Call target must be on T9
|
||||
Chain = CurDAG->getCopyToReg(Chain, dl, T9Reg, Load, InFlag);
|
||||
Chain = CurDAG->getCopyToReg(Chain, dl, Mips::T9, Load, InFlag);
|
||||
} else
|
||||
/// Indirect call
|
||||
Chain = CurDAG->getCopyToReg(Chain, dl, T9Reg, Callee, InFlag);
|
||||
Chain = CurDAG->getCopyToReg(Chain, dl, Mips::T9, Callee, InFlag);
|
||||
|
||||
// Map the JmpLink operands to JALR
|
||||
SDVTList NodeTys = CurDAG->getVTList(MVT::Other, MVT::Flag);
|
||||
SmallVector<SDValue, 8> Ops;
|
||||
Ops.push_back(CurDAG->getRegister(Mips::T9, MVT::i32));
|
||||
|
||||
for (unsigned i = 2, e = LastOpNum+1; i != e; ++i)
|
||||
Ops.push_back(Node->getOperand(i));
|
||||
Ops.push_back(Chain);
|
||||
Ops.push_back(Chain.getValue(1));
|
||||
|
||||
// Emit Jump and Link Register
|
||||
SDNode *ResNode = CurDAG->getMachineNode(Mips::JALR, dl, MVT::Other,
|
||||
MVT::Flag, T9Reg, Chain);
|
||||
Chain = SDValue(ResNode, 0);
|
||||
InFlag = SDValue(ResNode, 1);
|
||||
ReplaceUses(SDValue(Node, 0), Chain);
|
||||
ReplaceUses(SDValue(Node, 1), InFlag);
|
||||
SDNode *ResNode = CurDAG->getMachineNode(Mips::JALR, dl, NodeTys,
|
||||
&Ops[0], Ops.size());
|
||||
|
||||
// Replace Chain and InFlag
|
||||
ReplaceUses(SDValue(Node, 0), SDValue(ResNode, 0));
|
||||
ReplaceUses(SDValue(Node, 1), SDValue(ResNode, 1));
|
||||
return ResNode;
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ def SDT_MipsCallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
|
||||
def SDT_MipsCallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
|
||||
|
||||
// Call
|
||||
def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink, [SDNPHasChain,
|
||||
SDNPOutFlag]>;
|
||||
def MipsJmpLink : SDNode<"MipsISD::JmpLink",SDT_MipsJmpLink,
|
||||
[SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
|
||||
|
||||
// Hi and Lo nodes are used to handle global addresses. Used on
|
||||
// MipsISelLowering to lower stuff like GlobalAddress, ExternalSymbol
|
||||
@ -306,7 +306,7 @@ let isCall=1, hasDelaySlot=1,
|
||||
class JumpLink<bits<6> op, string instr_asm>:
|
||||
FJ< op,
|
||||
(outs),
|
||||
(ins calltarget:$target),
|
||||
(ins calltarget:$target, variable_ops),
|
||||
!strconcat(instr_asm, "\t$target"),
|
||||
[(MipsJmpLink imm:$target)], IIBranch>;
|
||||
|
||||
@ -315,14 +315,14 @@ let isCall=1, hasDelaySlot=1,
|
||||
FR< op,
|
||||
func,
|
||||
(outs),
|
||||
(ins CPURegs:$rs),
|
||||
(ins CPURegs:$rs, variable_ops),
|
||||
!strconcat(instr_asm, "\t$rs"),
|
||||
[(MipsJmpLink CPURegs:$rs)], IIBranch>;
|
||||
|
||||
class BranchLink<string instr_asm>:
|
||||
FI< 0x1,
|
||||
(outs),
|
||||
(ins CPURegs:$rs, brtarget:$target),
|
||||
(ins CPURegs:$rs, brtarget:$target, variable_ops),
|
||||
!strconcat(instr_asm, "\t$rs, $target"),
|
||||
[], IIBranch>;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user