From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id EE0563860C3B for ; Thu, 6 May 2021 07:02:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EE0563860C3B Received: by mail-ej1-x632.google.com with SMTP id s20so1161135ejr.9 for ; Thu, 06 May 2021 00:02:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HOja9ekQ+jf0Applgz5JpXe9gnj4YgFJsPx2Y/hfYrY=; b=AchYmfJkF9XP2pv35l/O56WSLSdEKWYmuOH0fE8o2Wbf6Rau/tAV81N1NhDO+QZkwx MMK9XIH/sc9tEUiCAuDKiszsA8Z1mDjy0wtbDHa1vXSitjF8rB77Z7owiDKwOK4I+zWy /+TZV9mG42hHN4PrQLhpxssnqTvGUISRnbYg+OXYZEkGWa149o+LpJxn+5HQFM2B6GtV SUhHUhMaTD4KOF/0GKCEcJD18txAVtwyrNFjL8mxX5UfRyq6g05jw5SrRCbdU/A0jwYT 0dzVyjDJMuv5K0f0UDsSr0gMwyZRsctj8ZBowFyfN0Q/C31NrxgaDKGh/i+nF8l1cDy9 bddQ== X-Gm-Message-State: AOAM531RFyZNMRKwfWhd4hxsFA9Q8GOygPocomDxakJV6ckhVnkKr6Uw YJ2BggOyIWs19uJbaSlgvfa3BwjaS6wwvjOZ0MM= X-Google-Smtp-Source: ABdhPJyBfPF2niGaB4ckC+ZKBynhjTqws20k17QDidE5beYTAM0R9YNs3BPnM15sQkEAfimxeKPn4Hx1JTJVyoutPN8= X-Received: by 2002:a17:906:3115:: with SMTP id 21mr2824703ejx.482.1620284538066; Thu, 06 May 2021 00:02:18 -0700 (PDT) MIME-Version: 1.0 References: <73469b28-307f-d2ad-6ac8-3502f6c12ba7@gmail.com> <83913be9-60c6-ee85-c688-0d106ac36659@gmail.com> In-Reply-To: <83913be9-60c6-ee85-c688-0d106ac36659@gmail.com> From: Richard Biener Date: Thu, 6 May 2021 09:02:07 +0200 Message-ID: Subject: Re: [PATCH] -Walloca-larger-than with constant sizes at -O0 (PR 100425) To: Martin Sebor Cc: gcc-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2021 07:02:20 -0000 On Wed, May 5, 2021 at 7:29 PM Martin Sebor wrote: > > On 5/5/21 1:32 AM, Richard Biener wrote: > > On Wed, May 5, 2021 at 4:20 AM Martin Sebor via Gcc-patches > > wrote: > >> > >> Even when explicitly enabled, -Walloca-larger-than doesn't run > >> unless optimization is enabled as well. This prevents diagnosing > >> alloca calls with constant arguments in excess of the limit that > >> could otherwise be flagged even at -O0, making the warning less > >> consistent and less useful than is possible. > >> > >> The attached patch enables -Walloca-larger-than for calls with > >> constant arguments in excess of the limit even at -O0 (variable > >> arguments are only handled with optimization, when VRP runs). > > > > Hmm, but then the pass runs even without -Walloca or -Walloca-larger-than > > or -Wvla[-larger-than]. It performs an IL walk we should avoid in those > > cases. > > > > So the patch is OK but can you please come up with a gate that disables > > the pass when all of the warnings it handles won't fire anyway? > > -W{alloca,vla}-larger-than=PTRDIFF_MAX are enabled by default so > the pass needs to do walk. > > FWIW, it would make sense to me to consolidate all the checking of > calls for arguments with excessive sizes/values into the same pass > and single walk (with code still in separate source files). As it > is, some are done in their own passes (like alloca and sprintf), > and others during expansion (-Wstringop-overflow), and others in > calls.c (-Walloc-size-larger-than). That leads to repetitive code > and inconsistent approaches and inconsistent false positives and > negatives (because some are done at -O0 but others require > optimization). True - that would be a nice cleanup (and speedup as well). Richard. > Martin > > > > > Thanks, > > Richard. > > > >> Martin >