This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/65219] New: GCC wrongly deletes a function which is not completely inlined.
- From: "bmei at broadcom dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 26 Feb 2015 11:45:33 +0000
- Subject: [Bug c/65219] New: GCC wrongly deletes a function which is not completely inlined.
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65219
Bug ID: 65219
Summary: GCC wrongly deletes a function which is not completely
inlined.
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bmei at broadcom dot com
Compile the following code with gcc 5.0 (
Target: x86_64-unknown-linux-gnu gcc version 5.0.0 20150226 (experimental)
[trunk revision 143368] (GCC))
~/scratch/install-x86/bin/gcc tst.c -O2 -S
#include <stdio.h>
inline int foo()
{
printf ("HEREEEEEEEEEEEEE\n");
printf ("HEREEEEEEEEEEEEE\n");
printf ("HEREEEEEEEEEEEEE\n");
printf ("HEREEEEEEEEEEEEE\n");
return 0;
}
int bar1 ()
{
return foo();
}
__attribute__((optimize("-funsafe-loop-optimizations")))
int bar2 ()
{
return foo();
}
Resulting assemble code:
.file "tst.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "HEREEEEEEEEEEEEE"
.section .text.unlikely,"ax",@progbits
.LCOLDB1:
.text
.LHOTB1:
.p2align 4,,15
.globl bar1
.type bar1, @function
bar1:
.LFB12:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $.LC0, %edi
call puts
movl $.LC0, %edi
call puts
movl $.LC0, %edi
call puts
movl $.LC0, %edi
call puts
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE12:
.size bar1, .-bar1
.section .text.unlikely
.LCOLDE1:
.text
.LHOTE1:
.section .text.unlikely
.LCOLDB2:
.text
.LHOTB2:
.p2align 4,,-1
.globl bar2
.type bar2, @function
bar2:
.LFB13:
.cfi_startproc
xorl %eax, %eax
jmp foo
.cfi_endproc
.LFE13:
.size bar2, .-bar2
.section .text.unlikely
.LCOLDE2:
.text
.LHOTE2:
.ident "GCC: (GNU) 5.0.0 20150226 (experimental) [trunk revision
143368]"
.section .note.GNU-stack,"",@progbits
The function body of foo is gone, but there is still a call to foo left in
bar2. I did some initial investigation. The bar1 function inline foo in einline
pass. But the bar2 cannot inline it because it has a function-specific optimize
attribute. For some reason the body of foo is just removed anyway.