diff options
author | Pablo Barrio <pablo.barrio@arm.com> | 2017-12-04 16:55:49 +0000 |
---|---|---|
committer | Pablo Barrio <pablo.barrio@arm.com> | 2017-12-04 16:55:49 +0000 |
commit | 2b4385846c86078e0012e7bfb2e8dc6476ae8dd0 (patch) | |
tree | 92da7bef7c42566026d201d446d44bf0adfd02b7 /llvm/lib/Target/ARM/ARMISelLowering.cpp | |
parent | f2fdc183b7bb771acd44bc9433557f36479fff79 (diff) | |
download | bcm5719-llvm-2b4385846c86078e0012e7bfb2e8dc6476ae8dd0.tar.gz bcm5719-llvm-2b4385846c86078e0012e7bfb2e8dc6476ae8dd0.zip |
Fix function pointer tail calls in armv8-M.base
Summary:
The compiler fails with the following error message:
fatal error: error in backend: ran out of registers during
register allocation
Tail call optimization for Armv8-M.base fails to meet all the required
constraints when handling calls to function pointers where the
arguments take up r0-r3. This is because the pointer to the
function to be called can only be stored in r0-r3, but these are
all occupied by arguments. This patch makes sure that tail call
optimization does not try to handle this type of calls.
Reviewers: chill, MatzeB, olista01, rengolin, efriedma
Reviewed By: olista01, efriedma
Subscribers: efriedma, aemerson, javed.absar, llvm-commits, kristof.beyls
Differential Revision: https://reviews.llvm.org/D40706
llvm-svn: 319664
Diffstat (limited to 'llvm/lib/Target/ARM/ARMISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/ARMISelLowering.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index d9893db3773..1726d6bcb30 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -2282,6 +2282,13 @@ ARMTargetLowering::IsEligibleForTailCallOptimization(SDValue Callee, assert(Subtarget->supportsTailCall()); + // Tail calls to function pointers cannot be optimized for Thumb1 if the args + // to the call take up r0-r3. The reason is that there are no legal registers + // left to hold the pointer to the function to be called. + if (Subtarget->isThumb1Only() && Outs.size() >= 4 && + !isa<GlobalAddressSDNode>(Callee.getNode())) + return false; + // Look for obvious safe cases to perform tail call optimization that do not // require ABI changes. This is what gcc calls sibcall. |