<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 --- - [Inliner] Callee with single call instruction not being inlined"
   href="https://llvm.org/bugs/show_bug.cgi?id=26115">26115</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Inliner] Callee with single call instruction not being inlined
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mcrosier@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Test case ([test-suite] SingleSource/UnitTests/2003-10-29-ScalarReplBug.c):

#include <stdio.h>

typedef struct {
  char name [80];
  int val;
  unsigned uval;
} data;

static int callback(void *d);
static void iter(int (*)(void*), void *);

static int callback(void *d)
{
  data *iter_data = (data *)d;

  printf("%u\n", iter_data->uval);
  return iter_data->uval == 0;
}

static void iter(int (*cb)(void*), void *d)
{
  cb(d);
}

int main()
{
  data d;

  d.uval = 0;
  iter(callback, &d);
  return 0;
}


On AArch64 we currently generate the following assembly:
--------------------------------------------------
    .text
    .file    "2003-10-29-ScalarReplBug.c"
    .globl    main
    .align    2
    .type    main,@function
main:                                   // @main
// BB#0:                                // %entry
    stp    x29, x30, [sp, #-16]!
    mov     x29, sp
    sub    sp, sp, #96             // =96
    add    x0, sp, #8              // =8
    str    wzr, [sp, #92]
    bl    iter
    mov     w0, wzr
    mov     sp, x29
    ldp    x29, x30, [sp], #16
    ret
.Lfunc_end0:
    .size    main, .Lfunc_end0-main

    .align    2
    .type    iter,@function
iter:                                   // @iter
// BB#0:                                // %entry
    b    callback
.Lfunc_end1:
    .size    iter, .Lfunc_end1-iter

    .align    2
    .type    callback,@function
callback:                               // @callback
// BB#0:                                // %entry
    stp    x20, x19, [sp, #-32]!
    stp    x29, x30, [sp, #16]
    mov     x19, x0
    ldr    w1, [x19, #84]
    adrp    x0, .L.str
    add    x0, x0, :lo12:.L.str
    add    x29, sp, #16            // =16
    bl    printf
    ldr    w8, [x19, #84]
    ldp    x29, x30, [sp, #16]
    cmp        w8, #0          // =0
    cset     w0, eq
    ldp    x20, x19, [sp], #32
    ret
.Lfunc_end2:
    .size    callback, .Lfunc_end2-callback

    .type    .L.str,@object          // @.str
    .section    .rodata.str1.1,"aMS",@progbits,1
.L.str:
    .asciz    "%u\n"
    .size    .L.str, 4


    .ident    "clang version 3.8.0 (trunk 257341) (llvm/trunk 257344)"
    .section    ".note.GNU-stack","",@progbits

--------------------------------------------------

Considering the body of iter is a single call to 'callback' I imagine it would
make sense to inline the call to iter.</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>