diff options
| author | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-03-20 17:57:23 +0000 |
|---|---|---|
| committer | Lauro Ramos Venancio <lauro.venancio@gmail.com> | 2007-03-20 17:57:23 +0000 |
| commit | a88c4a74f33c2b1018d0ab1b78018929857d4615 (patch) | |
| tree | a2599e50442317087a744816421a0b7053a111a7 /llvm/lib/Target/ARM/ARMISelLowering.cpp | |
| parent | cdf6823e10c3457dd524e002bf5d313880e0d17d (diff) | |
| download | bcm5719-llvm-a88c4a74f33c2b1018d0ab1b78018929857d4615.tar.gz bcm5719-llvm-a88c4a74f33c2b1018d0ab1b78018929857d4615.zip | |
bugfix: When the source register of CALL_NOLINK was LR, the following code was emitted:
mov lr, pc
bx lr
So, the function was not called.
llvm-svn: 35218
Diffstat (limited to 'llvm/lib/Target/ARM/ARMISelLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index afaea04b9d6..bd7fa5cf6c7 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -544,6 +544,24 @@ SDOperand ARMTargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) { Callee = DAG.getTargetExternalSymbol(Sym, getPointerTy()); } + // FIXME: handle tail calls differently. + unsigned CallOpc; + if (Subtarget->isThumb()) { + if (!Subtarget->hasV5TOps() && (!isDirect || isARMFunc)) + CallOpc = ARMISD::CALL_NOLINK; + else + CallOpc = isARMFunc ? ARMISD::CALL : ARMISD::tCALL; + } else { + CallOpc = (isDirect || Subtarget->hasV5TOps()) + ? ARMISD::CALL : ARMISD::CALL_NOLINK; + } + if (CallOpc == ARMISD::CALL_NOLINK) { + // On CALL_NOLINK we must move PC to LR + Chain = DAG.getCopyToReg(Chain, ARM::LR, + DAG.getRegister(ARM::PC, MVT::i32), InFlag); + InFlag = Chain.getValue(1); + } + std::vector<MVT::ValueType> NodeTys; NodeTys.push_back(MVT::Other); // Returns a chain NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use. @@ -558,17 +576,6 @@ SDOperand ARMTargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) { Ops.push_back(DAG.getRegister(RegsToPass[i].first, RegsToPass[i].second.getValueType())); - // FIXME: handle tail calls differently. - unsigned CallOpc; - if (Subtarget->isThumb()) { - if (!Subtarget->hasV5TOps() && (!isDirect || isARMFunc)) - CallOpc = ARMISD::CALL_NOLINK; - else - CallOpc = isARMFunc ? ARMISD::CALL : ARMISD::tCALL; - } else { - CallOpc = (isDirect || Subtarget->hasV5TOps()) - ? ARMISD::CALL : ARMISD::CALL_NOLINK; - } if (InFlag.Val) Ops.push_back(InFlag); Chain = DAG.getNode(CallOpc, NodeTys, &Ops[0], Ops.size()); |

