public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94818] New: GCC emits dead bodies of functions whose all calls have been eliminated by optimisations
@ 2020-04-28 12:43 felix.von.s at posteo dot de
  2020-04-28 13:36 ` [Bug ipa/94818] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: felix.von.s at posteo dot de @ 2020-04-28 12:43 UTC (permalink / raw)
  To: gcc-bugs

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__)).)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-20 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 12:43 [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
2020-04-28 13:36 ` [Bug ipa/94818] " rguenth at gcc dot gnu.org
2020-04-29  6:27 ` pinskia at gcc dot gnu.org
2021-07-20 22:23 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).