From patchwork Mon Oct 4 06:54:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 45750 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E637385840F for ; Mon, 4 Oct 2021 06:54:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E637385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633330491; bh=r6vCdoF5hPwsrclceyERMIWErls0gknk9fJMVkhpcdY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tcPjR9IdnYSP9jLFm6BE4/2XMQL7OS7Pf4C0rJtV3TAk/EwGVDeLheRXVwmU7+rES PKaMhYcIyA+BYUBVkcDwywHbd22Ujar2wFIjkn15tUnHtRJWsbdtdDl2tsy7c+Qh3a EcDgQzCvXAyMBI9mQAQOpYvad1kuqc+3UwTmPf6Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 82DC83858C3A for ; Mon, 4 Oct 2021 06:54:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82DC83858C3A Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-FpUxDWCjMGGg-xvHh_AFOQ-1; Mon, 04 Oct 2021 02:54:20 -0400 X-MC-Unique: FpUxDWCjMGGg-xvHh_AFOQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 111DACC621 for ; Mon, 4 Oct 2021 06:54:19 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79FEA1981C; Mon, 4 Oct 2021 06:54:18 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 1946sF4M1515467 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 4 Oct 2021 08:54:16 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1946sF771515466; Mon, 4 Oct 2021 08:54:15 +0200 To: GCC patches Subject: [PATCH] Remove static marker for range in alloca pass. Date: Mon, 4 Oct 2021 08:54:12 +0200 Message-Id: <20211004065412.1515395-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The m_ranges[] field in int_range are trees, so they live in GC space. Since invalid_range is static, it must be marked with GTY magic. However, calculating invalid_range is not particularly slow, or on a critical path, so we can just put it in local scope and recalculate every time. Tested on x86-64 Linux. Since this is more of a GC thing than a range thing, I'd like a nod from a global reviewer. OK? gcc/ChangeLog: PR tree-optimization/102560 * gimple-ssa-warn-alloca.c (alloca_call_type): Remove static marker for invalid_range. gcc/testsuite/ChangeLog: * g++.dg/Walloca2.C: New test. --- gcc/gimple-ssa-warn-alloca.c | 7 +++---- gcc/testsuite/g++.dg/Walloca2.C | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/g++.dg/Walloca2.C diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index 4fc7125d378..d59cea8d4ec 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -221,10 +221,9 @@ alloca_call_type (gimple *stmt, bool is_vla) && !r.varying_p ()) { // The invalid bits are anything outside of [0, MAX_SIZE]. - static int_range<2> invalid_range (build_int_cst (size_type_node, 0), - build_int_cst (size_type_node, - max_size), - VR_ANTI_RANGE); + int_range<2> invalid_range (build_int_cst (size_type_node, 0), + build_int_cst (size_type_node, max_size), + VR_ANTI_RANGE); r.intersect (invalid_range); if (r.undefined_p ()) diff --git a/gcc/testsuite/g++.dg/Walloca2.C b/gcc/testsuite/g++.dg/Walloca2.C new file mode 100644 index 00000000000..b6992d08bf3 --- /dev/null +++ b/gcc/testsuite/g++.dg/Walloca2.C @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-Walloca-larger-than=4207115063 -Wvla-larger-than=1233877270 -O2 --param ggc-min-heapsize=0 --param ggc-min-expand=0 -w" } +// { dg-require-effective-target alloca } + +int a; +char *b = static_cast(__builtin_alloca (a));