Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;
On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.
On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.Why aren’t checking for the presence of a tail call?
On Tue, Jun 28, 2016 at 8:11 PM, Mehdi Amini <mehdi...@apple.com> wrote:On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.Why aren’t checking for the presence of a tail call?Are you asking about if tail call optimization is enable or not? If not then above method is inspired from X86ISelLowering::canGuaranteeTCO().
On Jun 28, 2016, at 10:09 AM, Mehdi Amini via llvm-dev <llvm...@lists.llvm.org> wrote:
Sent from my iPhoneOn Tue, Jun 28, 2016 at 8:11 PM, Mehdi Amini <mehdi...@apple.com> wrote:On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.Why aren’t checking for the presence of a tail call?Are you asking about if tail call optimization is enable or not? If not then above method is inspired from X86ISelLowering::canGuaranteeTCO().Are we turning calls into tail calls during codegen?My assumption is that tail call is inferred on the IR, so you can inspect every *call site*.
On Jun 28, 2016, at 10:09 AM, Mehdi Amini via llvm-dev <llvm...@lists.llvm.org> wrote:
Sent from my iPhoneOn Tue, Jun 28, 2016 at 8:11 PM, Mehdi Amini <mehdi...@apple.com> wrote:On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.Why aren’t checking for the presence of a tail call?Are you asking about if tail call optimization is enable or not? If not then above method is inspired from X86ISelLowering::canGuaranteeTCO().Are we turning calls into tail calls during codegen?My assumption is that tail call is inferred on the IR, so you can inspect every *call site*.The final decision on whether to tail call or not is done during instruction selection (it is part of X86TargetLowering::LowerCall()/IsEligibleForTailCallOptimization() for example).
On Jun 28, 2016, at 11:34 AM, Mehdi Amini via llvm-dev <llvm...@lists.llvm.org> wrote:
Sent from my iPhoneOn Jun 28, 2016, at 10:09 AM, Mehdi Amini via llvm-dev <llvm...@lists.llvm.org> wrote:
Sent from my iPhoneOn Tue, Jun 28, 2016 at 8:11 PM, Mehdi Amini <mehdi...@apple.com> wrote:On Jun 27, 2016, at 12:25 PM, vivek pandya <vivekv...@gmail.com> wrote:Hello ,To solve this bug locally I have given preference to tail call optimization over local function related optimization in IPRA. I have added following method to achieve this:bool isEligibleForTailCallOptimization(Function *F) {CallingConv::ID CC = F->getCallingConv();if (CC == CallingConv::Fast || CC == CallingConv::GHC || CC == CallingConv::HiPE)return true;return false;}Any other suggestions are always welcomed.Why aren’t checking for the presence of a tail call?Are you asking about if tail call optimization is enable or not? If not then above method is inspired from X86ISelLowering::canGuaranteeTCO().Are we turning calls into tail calls during codegen?My assumption is that tail call is inferred on the IR, so you can inspect every *call site*.The final decision on whether to tail call or not is done during instruction selection (it is part of X86TargetLowering::LowerCall()/IsEligibleForTailCallOptimization() for example).Sorry i don't have access to the source code right now, can you clarify if the backend can tail call when the IR didn't mark the call as such, or if what you're referring to is "not honoring the tail call From the IR and demoting to a normal call?
I have tried out the following code which examines each call site in a module for tail call and do not perform optimization in such case: