public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95492] New: Avoid recursive inlining for -O2
@ 2020-06-03  7:23 david.bolvansky at gmail dot com
  2020-06-03  7:50 ` [Bug ipa/95492] " marxin at gcc dot gnu.org
  2020-06-03 11:41 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: david.bolvansky at gmail dot com @ 2020-06-03  7:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95492

            Bug ID: 95492
           Summary: Avoid recursive inlining for -O2
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.bolvansky at gmail dot com
  Target Milestone: ---

Test case from PR90949:

int puts(const char*);
void free(void*);
void* malloc(unsigned long);
#define NULL 0

struct Node
{
    struct Node* child;
};

void walk(struct Node* module, int cleanup)
{
    if (module == NULL) {
        return;
    }
    if (!cleanup) {
        puts("No cleanup");
    }
    walk(module->child, cleanup);
    if (cleanup) {
        free(module);
    }
}

int main()
{
    struct Node* node = malloc(sizeof(struct Node));
    node->child = NULL;
    walk(node, 1);
}

https://godbolt.org/z/aqVApt


Since GCC 10, GCC inlines recursion with -O2/-O3. With -O3, new bigger code is
justified, but for -O2, it is quite questionable whether GCC should inline it
or not (or possibly, less agressive "inlining" for -O2)

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

end of thread, other threads:[~2020-06-03 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  7:23 [Bug c/95492] New: Avoid recursive inlining for -O2 david.bolvansky at gmail dot com
2020-06-03  7:50 ` [Bug ipa/95492] " marxin at gcc dot gnu.org
2020-06-03 11:41 ` rguenth 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).