[llvm-bugs] [Bug 25617] New: ppc backend tail call optimization is not enabled

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 23 14:55:36 PST 2015


https://llvm.org/bugs/show_bug.cgi?id=25617

            Bug ID: 25617
           Summary: ppc backend tail call optimization is not enabled
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: carrot at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Compile the following code with command line
~/llvm/obj/bin/clang++ --target=powerpc64le-grtev4-linux-gnu -c -o t2.o -O2
-m64 -mvsx -mcpu=power8 t2.cpp -save-temps

extern void bar();
void fint()
{
  bar();
}

I got:

_Z4fintv:                               # @_Z4fintv
.Lfunc_begin0:
        .cfi_startproc
.Ltmp0:
        addis 2, 12, .TOC.-.Ltmp0 at ha
        addi 2, 2, .TOC.-.Ltmp0 at l
.Ltmp1:
        .localentry     _Z4fintv, .Ltmp1-.Ltmp0
# BB#0:                                 # %entry
        mflr 0
        std 31, -8(1)
        std 0, 16(1)
        stdu 1, -112(1)
.Ltmp2:
        .cfi_def_cfa_offset 112 
.Ltmp3:
        .cfi_offset r31, -8
.Ltmp4:
        .cfi_offset lr, 16
        mr 31, 1
.Ltmp5:
        .cfi_def_cfa_register r31 
        bl _Z3barv
        nop
        addi 1, 1, 112 
        ld 0, 16(1)
        ld 31, -8(1)
        mtlr 0
        blr


It is actually marked as tail call in the tail call optimization pass, but
later it is lowered to normal function call

*** IR Dump After Module Verifier ***
define void @_Z4fintv() #0 { 
entry:
  tail call void @_Z3barv()
  ret void 
}
# *** IR Dump After PowerPC DAG->DAG Pattern Instruction Selection ***: 
# Machine code for function _Z4fintv: SSA

BB#0: derived from LLVM BB %entry
        ADJCALLSTACKDOWN 96, %R1<imp-def,dead>, %R1<imp-use>
        BL8_NOP <ga:@_Z3barv>, <regmask %CR2 %CR3 %CR4 %F14 %F15 %F16 %F17 %F18
%F19 %F20 %F21 %F22 %F23 %F24 %F25 %F26 %F27 %F28 %F29 %F30 %F31 %R14 %R15 %R16
%R17 %R18 %R19 %R20 %R21 %R22 %R23 %R24 %R25 %R26 %R27 %R28 %R29 %R30 %R31 %V20
%V21 %V22 %V23 %V24 %V25 %V26 %V27 %V28 %V29 %V30 %V31 %VF20 %VF21 %VF22 %VF23
%VF24 %VF25 %VF26 %VF27 %VF28 %VF29 %VF30 %VF31 %X14 %X15 %X16 %X17 %X18 %X19
%X20 %X21 %X22 %X23 %X24 %X25 %X26 %X27 %X28 %X29 %X30 %X31 %CR2EQ %CR3EQ
%CR4EQ %CR2GT %CR3GT %CR4GT %CR2LT %CR3LT %CR4LT %CR2UN %CR3UN %CR4UN>,
%LR8<imp-def,dead>, %RM<imp-use>, %X2<imp-use>, %R1<imp-def>
        ADJCALLSTACKUP 96, 0, %R1<imp-def,dead>, %R1<imp-use>
        BLR8 %LR8<imp-use>, %RM<imp-use>

# End machine code for function _Z4fintv.


It turns out that option getTargetMachine().Options.GuaranteedTailCallOpt is
false.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151123/77516d49/attachment-0001.html>


More information about the llvm-bugs mailing list