[PATCH] D49465: [ARM] Enable tail calls for all Thumb1 targets.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 26 13:03:13 PDT 2018
efriedma planned changes to this revision.
efriedma added a comment.
Spent some time looking at David's testcases; looks like there are a few problems which lead to codesize increases:
1. SupportsTailCall = true changes the result of ARMTargetLowering::mayBeEmittedAsTailCall, which makes CodeGenPrepare clone a bunch of "ret" instructions. The result should be cleaned up again by tail merge, but the default tail merge threshold is too high ("bl foo; pop {r4, pc}" is two instructions, and the default threshold is 3 instructions).
2. The reverse transform in Thumb1FrameLowering::restoreCalleeSavedRegisters adds the wrong operands to the tPOP_RET instruction; it's based on the arguments to the tail call, not the returned values. As a consequence, tail merge thinks the instructions don't match. Also, there's a theoretical miscompile, but in practice the compiler probably won't insert code there anyway, so I'm not sure how to trigger it. Not sure how to fix this; I don't think we track the necessary information anywhere. (Tail merge could be fixed to merge instructions with mismatched implicit operands, which is probably a good idea anyway, but that wouldn't really solve the underlying incorrect modeling.)
So this needs more work.
Repository:
rL LLVM
https://reviews.llvm.org/D49465
More information about the llvm-commits
mailing list