From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 612653851880; Wed, 23 Nov 2022 17:57:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 612653851880 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669226277; bh=U8EBkGiFI9Px0qmo5DLkZTjQjcdu47EtSZ3kEBWomRg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cdv/AZJUNd/x5MNIa7zshj9iFnfIThN2AqkSJ8K1inW7DCiG2RmCTK52r7RvKPygu xVV8csiH9Q+CSzO8qCtlLZSDo6Ul+dE+DpmRxFJdZW/4YI+143qUv4iHd2hCIPAni5 UfzGwjiT4rIZVxmjzHkFdOo0FgLmE+uPtvoM6JsQ= From: "law at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107831] Missed optimization: -fclash-stack-protection causes unnecessary code generation for dynamic stack allocations that are clearly less than a page Date: Wed, 23 Nov 2022 17:57:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: law at gcc dot gnu.org 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: Message-ID: In-Reply-To: References: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107831 --- Comment #5 from Jeffrey A. Law --- Right. You also have to know the distance from the last probe (possibly an implicit one) to the start of the alloca space before you can contemplate eliding the probes in alloca space. There's a hook we can use, but it was = more meant for AArch64 IIRC, but we might be able to use it for this purpose. You also have to worry about dynamic allocations in a loop. A single byte alloca could jump the stack if it's inside loop with a suitable number of iterations. In general, the model taken was to try and minimize explicit probes in the common case (ie, function entry) at the expense of taking additional probes= in the uncommon case (dynamic allocations).=