[LLVMbugs] [Bug 8233] New: Sibcall optimization rejects sret-using functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Sep 26 06:06:00 PDT 2010


           Summary: Sibcall optimization rejects sret-using functions
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: fvbommel at wxs.nl
                CC: llvmbugs at cs.uiuc.edu

Sibcall optimization does not take place when 'sret' is used on X86-64. For
$ cat test.ll
; ModuleID = '/home/urxae/.ccache/test.tmp.s010625.15525.ii'
target datalayout =
target triple = "x86_64-unknown-linux-gnu"

%struct.Foo = type { [3 x i64] }

define void @_Z10tailcallerv(%struct.Foo* sret %agg.result) nounwind {
  tail call void @_Z10tailcalleev(%struct.Foo* sret %agg.result) nounwind
  ret void

declare void @_Z10tailcalleev(%struct.Foo* sret) nounwind
$ llc test.ll -o -
    .file    "test.ll"
    .globl    _Z10tailcallerv
    .align    16, 0x90
    .type    _Z10tailcallerv, at function
_Z10tailcallerv:                        # @_Z10tailcallerv
# BB#0:                                 # %entry
    pushq    %rbx
    movq    %rdi, %rbx
    callq    _Z10tailcalleev
    movq    %rbx, %rax
    popq    %rbx
    .size    _Z10tailcallerv, .Ltmp0-_Z10tailcallerv

    .section    .note.GNU-stack,"", at progbits

This despite the fact that the code for tailcaller() here only needs to be a
jump to tailcallee()...

Removing sret from tailcaller() doesn't help, but removing it from both works.
(Note: removing it only from tailcallee() *shouldn't* work, because then
tailcaller() can't copy %rdi to %rax on exit)

32-bit x86 code seems to have this problem as well, by the way.

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