From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3836385DC00; Wed, 3 Jun 2020 07:23:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3836385DC00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1591168999; bh=T9qKIjzQWpQTuDr80KwviNSFtzMoz9oZDFoWpQ0IR1s=; h=From:To:Subject:Date:From; b=s20wbJhZ8sote7rbIojZhLxPYQfxgpaoVZqAp1X9XyqsBJ75D8JPBSZEI3aReZMC5 6VaSZoNl2AwFtTKGUG4NaeaJbG2awtjyCUd5L4rstM7ZJA7PB3uSm6u57I0EPGbo/6 64ep6cu211t584X/t3dEs5UzK5QGj8TE1eElmkbg= From: "david.bolvansky at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/95492] New: Avoid recursive inlining for -O2 Date: Wed, 03 Jun 2020 07:23:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david.bolvansky at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2020 07:23:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95492 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 =3D=3D NULL) { return; } if (!cleanup) { puts("No cleanup"); } walk(module->child, cleanup); if (cleanup) { free(module); } } int main() { struct Node* node =3D malloc(sizeof(struct Node)); node->child =3D 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)=