diff options
author | Artyom Skrobov <Artyom.Skrobov@arm.com> | 2015-09-28 09:44:11 +0000 |
---|---|---|
committer | Artyom Skrobov <Artyom.Skrobov@arm.com> | 2015-09-28 09:44:11 +0000 |
commit | ad8a0638f7fa14f9737feeac12718fb62389b980 (patch) | |
tree | 71f6aa7efb7badd4f837ce885aaaca85c901b948 /llvm/lib/Target/ARM/ARMSubtarget.cpp | |
parent | c8c77d46efbe1d33a07a425bd84d82eae30bd959 (diff) | |
download | llvm-ad8a0638f7fa14f9737feeac12718fb62389b980.zip llvm-ad8a0638f7fa14f9737feeac12718fb62389b980.tar.gz llvm-ad8a0638f7fa14f9737feeac12718fb62389b980.tar.bz2 |
[ARM] Avoid redundant checks for isThumb1Only() after supportsTailCall()
supportsTailCall() has two callers. Both of them double-check isThumb1Only(),
and refuse to proceed with tail-calling in that case.
Therefore, it makes sense to move this check to
ARMSubtarget::initSubtargetFeatures, where SupportsTailCall is initialized;
and to eliminate the extra checks at the call sites.
Following a review comment, added an "assert(supportsTailCall())"
in IsEligibleForTailCall.
NFC.
llvm-svn: 248703
Diffstat (limited to 'llvm/lib/Target/ARM/ARMSubtarget.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMSubtarget.cpp | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.cpp b/llvm/lib/Target/ARM/ARMSubtarget.cpp index aff38c0..e0d9939 100644 --- a/llvm/lib/Target/ARM/ARMSubtarget.cpp +++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp @@ -193,10 +193,28 @@ void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { if (isTargetNaCl()) stackAlignment = 16; - if (isTargetMachO()) - SupportsTailCall = !isTargetIOS() || !getTargetTriple().isOSVersionLT(5, 0); - else - SupportsTailCall = !isThumb1Only(); + // FIXME: Completely disable sibcall for Thumb1 since ThumbRegisterInfo:: + // emitEpilogue is not ready for them. Thumb tail calls also use t2B, as + // the Thumb1 16-bit unconditional branch doesn't have sufficient relocation + // support in the assembler and linker to be used. This would need to be + // fixed to fully support tail calls in Thumb1. + // + // Doing this is tricky, since the LDM/POP instruction on Thumb doesn't take + // LR. This means if we need to reload LR, it takes an extra instructions, + // which outweighs the value of the tail call; but here we don't know yet + // whether LR is going to be used. Probably the right approach is to + // generate the tail call here and turn it back into CALL/RET in + // emitEpilogue if LR is used. + + // Thumb1 PIC calls to external symbols use BX, so they can be tail calls, + // but we need to make sure there are enough registers; the only valid + // registers are the 4 used for parameters. We don't currently do this + // case. + + SupportsTailCall = !isThumb1Only(); + + if (isTargetMachO() && isTargetIOS() && getTargetTriple().isOSVersionLT(5, 0)) + SupportsTailCall = false; switch (IT) { case DefaultIT: |