<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - llvm generates many push and pop"
   href="https://llvm.org/bugs/show_bug.cgi?id=27661">27661</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm generates many push and pop
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>hjl.tools@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>david.l.kreitzer@intel.com, llvm-bugs@lists.llvm.org, zia.ansari@intel.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>At -O2 for x86-64, llvm generates an extra subq and many push/pop

---
extern void foo1 (void *, void *, void *, void *, void *, void *, int, int,
void *);
extern void foo2 (void *, void *, void *, void *, void *, void *, int, void *);

void
bar (int x)
{
  int i1, i2, i3, i4, i5, i6;
  int i;
  foo1 (&i1, &i2, &i3, &i4, &i5, &i6, 7, 8, &i);
  foo2 (&i1, &i2, &i3, &i4, &i5, &i6, 8, &i);
}
---

bar:                                    # @bar
    .cfi_startproc
# BB#0:
    pushq    %rbp
.Ltmp0:
    .cfi_def_cfa_offset 16
    pushq    %r15
.Ltmp1:
    .cfi_def_cfa_offset 24
    pushq    %r14
.Ltmp2:
    .cfi_def_cfa_offset 32
    pushq    %r13
.Ltmp3:
    .cfi_def_cfa_offset 40
    pushq    %r12
.Ltmp4:
    .cfi_def_cfa_offset 48
    pushq    %rbx
.Ltmp5:
    .cfi_def_cfa_offset 56
    subq    $40, %rsp
.Ltmp6:
    .cfi_def_cfa_offset 96
.Ltmp7:
    .cfi_offset %rbx, -56
.Ltmp8:
    .cfi_offset %r12, -48
.Ltmp9:
    .cfi_offset %r13, -40
.Ltmp10:
    .cfi_offset %r14, -32
.Ltmp11:
    .cfi_offset %r15, -24
.Ltmp12:
    .cfi_offset %rbp, -16
    subq    $8, %rsp  <<<<<<<<<<<<<<<  Extra subq.
.Ltmp13:
    .cfi_adjust_cfa_offset 8
    leaq    20(%rsp), %rax
    leaq    44(%rsp), %rbx
    leaq    40(%rsp), %r14
    leaq    36(%rsp), %r15
    leaq    32(%rsp), %r12
    leaq    28(%rsp), %r13
    leaq    24(%rsp), %rbp
    movq    %rbx, %rdi
    movq    %r14, %rsi
    movq    %r15, %rdx
    movq    %r12, %rcx
    movq    %r13, %r8
    movq    %rbp, %r9
    pushq    %rax
.Ltmp14:
    .cfi_adjust_cfa_offset 8
    pushq    $8
.Ltmp15:
    .cfi_adjust_cfa_offset 8
    pushq    $7
.Ltmp16:
    .cfi_adjust_cfa_offset 8
    callq    foo1
    addq    $32, %rsp
.Ltmp17:
    .cfi_adjust_cfa_offset -32
    movq    %rbx, %rdi
    movq    %r14, %rsi
    movq    %r15, %rdx
    movq    %r12, %rcx
    movq    %r13, %r8
    movq    %rbp, %r9
    leaq    12(%rsp), %rax
    pushq    %rax
.Ltmp18:
    .cfi_adjust_cfa_offset 8
    pushq    $8
.Ltmp19:
    .cfi_adjust_cfa_offset 8
    callq    foo2
    addq    $56, %rsp
.Ltmp20:
    .cfi_adjust_cfa_offset -16
    popq    %rbx
    popq    %r12
    popq    %r13
    popq    %r14
    popq    %r15
    popq    %rbp
    retq

GCC 5.3.1 generates

bar:
.LFB0:
    .cfi_startproc
    pushq    %rbx
    .cfi_def_cfa_offset 16
    .cfi_offset 3, -16
    subq    $40, %rsp
    .cfi_def_cfa_offset 56
    leaq    36(%rsp), %rbx
    pushq    %rbx
    .cfi_def_cfa_offset 64
    pushq    $8
    .cfi_def_cfa_offset 72
    pushq    $7
    .cfi_def_cfa_offset 80
    leaq    56(%rsp), %r9
    leaq    52(%rsp), %r8
    leaq    48(%rsp), %rcx
    leaq    44(%rsp), %rdx
    leaq    40(%rsp), %rsi
    leaq    36(%rsp), %rdi
    call    foo1
    addq    $32, %rsp
    .cfi_def_cfa_offset 48
    pushq    %rbx
    .cfi_def_cfa_offset 56
    pushq    $8
    .cfi_def_cfa_offset 64
    leaq    40(%rsp), %r9
    leaq    36(%rsp), %r8
    leaq    32(%rsp), %rcx
    leaq    28(%rsp), %rdx
    leaq    24(%rsp), %rsi
    leaq    20(%rsp), %rdi
    call    foo2
    addq    $48, %rsp
    .cfi_def_cfa_offset 16
    popq    %rbx
    .cfi_def_cfa_offset 8
    ret</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>