[LLVMbugs] [Bug 10432] New: Inefficient code for passing an alloca as argument to a function

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jul 21 10:29:42 PDT 2011


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

           Summary: Inefficient code for passing an alloca as argument to
                    a function
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Given

extern bool ToNumberSlow(double *dp);
void Interpret() {
  double l, r;
  for (;;) {
    ToNumberSlow(&l);
    ToNumberSlow(&r);
  }
}

We produce what is probably the best IL:

define void @_Z9Interpretv() noreturn nounwind uwtable {
entry:
  %l = alloca double, align 8
  %r = alloca double, align 8
  br label %for.cond
for.cond:
  %call = call zeroext i1 @_Z12ToNumberSlowPd(double* %l) nounwind
  %call1 = call zeroext i1 @_Z12ToNumberSlowPd(double* %r) nounwind
  br label %for.cond
}
declare zeroext i1 @_Z12ToNumberSlowPd(double*)

but that then codegens to:

        pushq   %r14
        pushq   %rbx
        subq    $24, %rsp
        leaq    16(%rsp), %r14
        leaq    8(%rsp), %rbx
        .align  16, 0x90
.LBB0_1:
        movq    %r14, %rdi
        callq   _Z12ToNumberSlowPd
        movq    %rbx, %rdi
        callq   _Z12ToNumberSlowPd
        jmp     .LBB0_1

gcc produces

        subq    $24, %rsp
.L2:
        movq    %rsp, %rdi
        call    _Z12ToNumberSlowPd
        leaq    8(%rsp), %rdi
        call    _Z12ToNumberSlowPd
        jmp     .L2

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