[LLVMbugs] [Bug 9487] New: optimiser (inliner) breaks tail calls

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 15 15:18:38 PDT 2011


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

           Summary: optimiser (inliner) breaks tail calls
           Product: new-bugs
           Version: 2.9
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: davidterei at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6325)
 --> (http://llvm.org/bugs/attachment.cgi?id=6325)
Testcase

Was testing the llvm-29rc1 and found that the optimiser breaks tail calls. For
example if you run 'opt -inline' on the file attached to this bug then you get
an optimised file which has lines like so:

  tail call cc10 void %ln1ZU.i(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64
ptrtoint ([0 x i64]* @sES_closure to i64), i64 ptrtoint ([0 x i64]*
@sES_closure to i64), i64 %R3_Arg) nounwind
  br label %rBL_info.exit

c1ZP.i:                                           ; preds = %n26p
  tail call cc10 void @sEH_info(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64
ptrtoint ([0 x i64]* @sES_closure to i64), i64 ptrtoint ([0 x i64]*
@sES_closure to i64), i64 %R3_Arg) nounwind
  br label %rBL_info.exit

rBL_info.exit:                                    ; preds = %c1ZP.i, %n1ZQ.i
  ret void

Which has change two previous tail calls into non-tail calls which is a problem
for some compilers such as GHC which will segfault now as they expect calls to
be tail calls.

Steps to repoduce
-----------------

1) Run following commands over file attached:

opt -O3 file.ll | llc -O3 -o file.s

file.s will now have 'ret' statements in it. If same command is run under
llvm-28 the calls are tail calls as expected.

2) Problem seems to be introduced by inliner pass.

opt -inline file.ll -o file-inlined.ll

Seems to show the problem (see above).

-- 
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