[llvm-bugs] [Bug 26115] New: [Inliner] Callee with single call instruction not being inlined
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jan 11 10:53:57 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26115
Bug ID: 26115
Summary: [Inliner] Callee with single call instruction not
being inlined
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: mcrosier at codeaurora.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
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, at 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, at function
iter: // @iter
// BB#0: // %entry
b callback
.Lfunc_end1:
.size iter, .Lfunc_end1-iter
.align 2
.type callback, at 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, at object // @.str
.section .rodata.str1.1,"aMS", at 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","", at progbits
--------------------------------------------------
Considering the body of iter is a single call to 'callback' I imagine it would
make sense to inline the call to iter.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160111/34baae21/attachment.html>
More information about the llvm-bugs
mailing list