[Bug tree-optimization/94818] New: GCC emits dead bodies of functions whose all calls have been eliminated by optimisations
felix.von.s at posteo dot de
gcc-bugzilla@gcc.gnu.org
Tue Apr 28 12:43:51 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94818
Bug ID: 94818
Summary: GCC emits dead bodies of functions whose all calls
have been eliminated by optimisations
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: felix.von.s at posteo dot de
Target Milestone: ---
Target: x86_64-linux-gnu
In this code:
__attribute__((__warning__("argh")))
static void foo(void) {
__asm__ (
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
);
}
void bar0(int x) {
if (__builtin_constant_p(x))
foo();
}
void bar1(int x) {
if (__builtin_constant_p(x))
foo();
}
No calls to foo are emitted in the final output, and GCC knows this, since no
warnings are emitted. However, GCC will still emit a function body for foo,
unless either the __asm__ statement is removed or both conditions are changed
to integer constant expressions, so that the function is eliminated by one of
the inlining passes.
(I decided to demonstrate it this way instead of using
__attribute__((__noinline__)), just to make sure this is not related to
__attribute__((__noinline__)) somehow implying __attribute__((__used__)).)
More information about the Gcc-bugs
mailing list