[LLVMbugs] [Bug 9222] New: -tailcallopt misses optimization for default(CallingConv::C) calling conversion

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 14 17:25:38 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9222

           Summary: -tailcallopt misses optimization for
                    default(CallingConv::C) calling conversion
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Keywords: code-quality
          Severity: normal
          Priority: P
         Component: Backend: X86
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: geek4civic at gmail.com
                CC: llvmbugs at cs.uiuc.edu


I understand -tailcallopt enables "fastcc" as "guaranteed tailcall", to emit
fastcc functions as callee stack rewind. It is known to work well.

In contrast, it seems -tailcallopt disables tailjmp optimization for default
calling conversions. I guess it would be misoptimization.

In X86ISelLowering.cpp:

static bool IsTailCallConvention(CallingConv::ID CC) {
  return (CC == CallingConv::Fast || CC == CallingConv::GHC);
}

X86TargetLowering::IsEligibleForTailCallOptimization(),

  if (GuaranteedTailCallOpt) {
    if (IsTailCallConvention(CalleeCC) && CCMatch)
      return true;
    return false;
  }

It seems CallingConv::C would be missed.


; example
define void @caller_c() nounwind {
entry:
 tail call void @callee_c()
 ret void
}
declare void @callee_c() nounwind

define fastcc void @caller_f() nounwind {
entry:
 tail call fastcc void @callee_f()
 ret void
}
declare fastcc void @callee_f() nounwind


; llc -mtriple=x86_64-linux #(w/o -tailcallopt)
caller_c:
        jmp     callee_c                # TAILCALL
caller_f:
        jmp     callee_f                # TAILCALL

; llc -mtriple=x86_64-linux -tailcallopt
caller_c:
        pushq   %rax
        callq   callee_c
        popq    %rax
        ret
caller_f:
        pushq   %rax       # bug 8925
        popq    %rax
        jmp     callee_f                # TAILCALL

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list