mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
Fix bug in which nodes that write to argument registers do not get glued with the JALR node. Patch by Sasa Stankovic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131714 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1135,17 +1135,6 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
|
Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
|
||||||
&MemOpChains[0], MemOpChains.size());
|
&MemOpChains[0], MemOpChains.size());
|
||||||
|
|
||||||
// Build a sequence of copy-to-reg nodes chained together with token
|
|
||||||
// chain and flag operands which copy the outgoing args into registers.
|
|
||||||
// The InFlag in necessary since all emitted instructions must be
|
|
||||||
// stuck together.
|
|
||||||
SDValue InFlag;
|
|
||||||
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
|
||||||
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
|
|
||||||
RegsToPass[i].second, InFlag);
|
|
||||||
InFlag = Chain.getValue(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
|
// If the callee is a GlobalAddress/ExternalSymbol node (quite common, every
|
||||||
// direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
|
// direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol
|
||||||
// node so that legalize doesn't hack it.
|
// node so that legalize doesn't hack it.
|
||||||
@@ -1172,6 +1161,8 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
LoadSymAddr = true;
|
LoadSymAddr = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDValue InFlag;
|
||||||
|
|
||||||
// Create nodes that load address of callee and copy it to T9
|
// Create nodes that load address of callee and copy it to T9
|
||||||
if (IsPIC) {
|
if (IsPIC) {
|
||||||
if (LoadSymAddr) {
|
if (LoadSymAddr) {
|
||||||
@@ -1197,6 +1188,16 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,
|
|||||||
Callee = DAG.getRegister(Mips::T9, MVT::i32);
|
Callee = DAG.getRegister(Mips::T9, MVT::i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build a sequence of copy-to-reg nodes chained together with token
|
||||||
|
// chain and flag operands which copy the outgoing args into registers.
|
||||||
|
// The InFlag in necessary since all emitted instructions must be
|
||||||
|
// stuck together.
|
||||||
|
for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
|
||||||
|
Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
|
||||||
|
RegsToPass[i].second, InFlag);
|
||||||
|
InFlag = Chain.getValue(1);
|
||||||
|
}
|
||||||
|
|
||||||
// MipsJmpLink = #chain, #target_address, #opt_in_flags...
|
// MipsJmpLink = #chain, #target_address, #opt_in_flags...
|
||||||
// = Chain, Callee, Reg#1, Reg#2, ...
|
// = Chain, Callee, Reg#1, Reg#2, ...
|
||||||
//
|
//
|
||||||
|
@@ -4,24 +4,24 @@ define void @f1(i64 %ll1, float %f, i64 %ll, i32 %i, float %f2) nounwind {
|
|||||||
entry:
|
entry:
|
||||||
; CHECK: addu $[[R1:[0-9]+]], $zero, $5
|
; CHECK: addu $[[R1:[0-9]+]], $zero, $5
|
||||||
; CHECK: addu $[[R0:[0-9]+]], $zero, $4
|
; CHECK: addu $[[R0:[0-9]+]], $zero, $4
|
||||||
|
; CHECK: lw $25, %call16(ff1)
|
||||||
; CHECK: ori $6, ${{[0-9]+}}, 3855
|
; CHECK: ori $6, ${{[0-9]+}}, 3855
|
||||||
; CHECK: ori $7, ${{[0-9]+}}, 22136
|
; CHECK: ori $7, ${{[0-9]+}}, 22136
|
||||||
; CHECK: lw $25, %call16(ff1)
|
|
||||||
; CHECK: jalr
|
; CHECK: jalr
|
||||||
tail call void @ff1(i32 %i, i64 1085102592623924856) nounwind
|
tail call void @ff1(i32 %i, i64 1085102592623924856) nounwind
|
||||||
; CHECK: lw $[[R2:[0-9]+]], 96($sp)
|
; CHECK: lw $25, %call16(ff2)
|
||||||
; CHECK: lw $[[R3:[0-9]+]], 100($sp)
|
; CHECK: lw $[[R2:[0-9]+]], 88($sp)
|
||||||
|
; CHECK: lw $[[R3:[0-9]+]], 92($sp)
|
||||||
; CHECK: addu $4, $zero, $[[R2]]
|
; CHECK: addu $4, $zero, $[[R2]]
|
||||||
; CHECK: addu $5, $zero, $[[R3]]
|
; CHECK: addu $5, $zero, $[[R3]]
|
||||||
; CHECK: lw $25, %call16(ff2)
|
|
||||||
; CHECK: jalr $25
|
; CHECK: jalr $25
|
||||||
tail call void @ff2(i64 %ll, double 3.000000e+00) nounwind
|
tail call void @ff2(i64 %ll, double 3.000000e+00) nounwind
|
||||||
%sub = add nsw i32 %i, -1
|
%sub = add nsw i32 %i, -1
|
||||||
; CHECK: sw $[[R0]], 24($sp)
|
; CHECK: sw $[[R0]], 24($sp)
|
||||||
; CHECK: sw $[[R1]], 28($sp)
|
; CHECK: sw $[[R1]], 28($sp)
|
||||||
|
; CHECK: lw $25, %call16(ff3)
|
||||||
; CHECK: addu $6, $zero, $[[R2]]
|
; CHECK: addu $6, $zero, $[[R2]]
|
||||||
; CHECK: addu $7, $zero, $[[R3]]
|
; CHECK: addu $7, $zero, $[[R3]]
|
||||||
; CHECK: lw $25, %call16(ff3)
|
|
||||||
; CHECK: jalr $25
|
; CHECK: jalr $25
|
||||||
tail call void @ff3(i32 %i, i64 %ll, i32 %sub, i64 %ll1) nounwind
|
tail call void @ff3(i32 %i, i64 %ll, i32 %sub, i64 %ll1) nounwind
|
||||||
ret void
|
ret void
|
||||||
|
Reference in New Issue
Block a user