From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id C5D5F393C846 for ; Tue, 25 May 2021 16:17:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C5D5F393C846 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-fzE6SM4DOyi8-UAw5wp2SA-1; Tue, 25 May 2021 12:17:26 -0400 X-MC-Unique: fzE6SM4DOyi8-UAw5wp2SA-1 Received: by mail-wm1-f71.google.com with SMTP id u203-20020a1cddd40000b029016dbb86d796so6076463wmg.0 for ; Tue, 25 May 2021 09:17:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=4XCOKpCCuvpJVgnPxwaVdmtOy0y9spzZK6fQYFyNP2o=; b=nWT74IGGa59qofLa9TjsO9KJuXeOSF+lpJaifjysTd2lW5aJBRk4JzOIsilEtPz6QY Z+sIURmLDTL8b88rR2it2lUcOhaRsr7Ic5i9ZyaSwxuZSaN/515FPF7V20nMaXitIUEa xBO8UsNY2xnqURFEiH2wLMS9uDu0e1AmVBsb3ipUGV/qjRr6x3ys8ZjZ0wRCXOGVh2Si lUU1tzdVlvhF+/Vi2mfuV7tszhhHKlMgQA4R0Ht9RKX4TPxm5o46wH/jxIljvmu0DpNZ Ha3weAWfvm9Yu3u1JOsO3bLBDiMXl11qygpCMH/irg6cJLyBZvVj1E6a6pLGLAkVoCrt 50ZA== X-Gm-Message-State: AOAM532pT3wqV1zkizlv4QPKNPRbHKHhZ71wOqIhT8vL/p6FiTNIWkAr WOM1Y0NnaDirRA9jOl1gloV0Ne23S3YjXCiachsA+MG43pSZRlTh/KGOCcV/j19obBpg4Wk/eTr pAHzkvnsQPuLJh39eIQ== X-Received: by 2002:a05:6000:11ce:: with SMTP id i14mr28286514wrx.221.1621959445200; Tue, 25 May 2021 09:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2wal8YlFjCUCBgwhAUjHogQr0YXIoSfG4trpzIDahpB81o6bd3ZRVmVVvv57Vmjp1F8iioA== X-Received: by 2002:a05:6000:11ce:: with SMTP id i14mr28286492wrx.221.1621959445057; Tue, 25 May 2021 09:17:25 -0700 (PDT) Received: from abulafia.quesejoda.com ([95.169.237.215]) by smtp.gmail.com with ESMTPSA id c6sm9790325wrt.20.2021.05.25.09.17.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 May 2021 09:17:24 -0700 (PDT) Subject: Re: [PATCH 2/5] Convert Walloca pass to RANGE_QUERY(cfun). To: GCC patches , Andrew MacLeod Cc: Jeff Law , Martin Sebor References: <20210521113954.1148075-1-aldyh@redhat.com> <20210521113954.1148075-2-aldyh@redhat.com> From: Aldy Hernandez Message-ID: <21132288-5510-3d08-79fa-3031158b5865@redhat.com> Date: Tue, 25 May 2021 18:17:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210521113954.1148075-2-aldyh@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="------------A512D68BF1D3910C8438F9D6" Content-Language: en-US X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: Tue, 25 May 2021 16:17:30 -0000 This is a multi-part message in MIME format. --------------A512D68BF1D3910C8438F9D6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Adjustments per discussion. OK pending tests? Aldy --------------A512D68BF1D3910C8438F9D6 Content-Type: text/x-patch; charset=UTF-8; name="0003-Convert-Walloca-pass-to-get_range_query.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-Convert-Walloca-pass-to-get_range_query.patch" >From 97bedf7dc0a7860802461b5fd3e72b687076ae30 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 19 May 2021 18:27:47 +0200 Subject: [PATCH 3/5] Convert Walloca pass to get_range_query. This patch converts the Walloca pass to use an on-demand ranger accesible with get_range_query instead of having to create a ranger and pass it around. gcc/ChangeLog: * gimple-ssa-warn-alloca.c (alloca_call_type): Use get_range_query instead of query argument. (pass_walloca::execute): Enable and disable global ranger. --- gcc/gimple-ssa-warn-alloca.c | 10 ++++++---- gcc/testsuite/gcc.dg/Wstringop-overflow-55.c | 8 ++++---- gcc/testsuite/gcc.dg/pr80776-1.c | 4 +--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gcc/gimple-ssa-warn-alloca.c b/gcc/gimple-ssa-warn-alloca.c index e9a24d4d1d0..72480f1d8cb 100644 --- a/gcc/gimple-ssa-warn-alloca.c +++ b/gcc/gimple-ssa-warn-alloca.c @@ -165,7 +165,7 @@ adjusted_warn_limit (bool idx) // call was created by the gimplifier for a VLA. static class alloca_type_and_limit -alloca_call_type (range_query &query, gimple *stmt, bool is_vla) +alloca_call_type (gimple *stmt, bool is_vla) { gcc_assert (gimple_alloca_call_p (stmt)); tree len = gimple_call_arg (stmt, 0); @@ -217,7 +217,7 @@ alloca_call_type (range_query &query, gimple *stmt, bool is_vla) int_range_max r; if (warn_limit_specified_p (is_vla) && TREE_CODE (len) == SSA_NAME - && query.range_of_expr (r, len, stmt) + && get_range_query (cfun)->range_of_expr (r, len, stmt) && !r.varying_p ()) { // The invalid bits are anything outside of [0, MAX_SIZE]. @@ -256,7 +256,7 @@ in_loop_p (gimple *stmt) unsigned int pass_walloca::execute (function *fun) { - gimple_ranger ranger; + gimple_ranger *ranger = enable_ranger (fun); basic_block bb; FOR_EACH_BB_FN (bb, fun) { @@ -290,7 +290,7 @@ pass_walloca::execute (function *fun) continue; class alloca_type_and_limit t - = alloca_call_type (ranger, stmt, is_vla); + = alloca_call_type (stmt, is_vla); unsigned HOST_WIDE_INT adjusted_alloca_limit = adjusted_warn_limit (false); @@ -383,6 +383,8 @@ pass_walloca::execute (function *fun) } } } + ranger->export_global_ranges (); + disable_ranger (fun); return 0; } diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c index 25f5b82d9be..8df5cb629ae 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-55.c @@ -66,7 +66,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i) { i |= 1; - char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } } + char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" } char *p0 = ca5; // offset char *p1 = p0 + i; // 1-5 char *p2 = p1 + i; // 2-5 @@ -74,7 +74,7 @@ void warn_ptrdiff_anti_range_add (ptrdiff_t i) char *p4 = p3 + i; // 4-5 char *p5 = p4 + i; // 5 - memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } } + memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" } sink (p0, p1, p2, p3, p4, p5); } @@ -83,7 +83,7 @@ void warn_int_anti_range (int i) { i |= 1; - char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" { xfail *-*-* } } + char ca5[5]; // { dg-message "at offset \\\[1, 5]" "pr?????" } char *p0 = ca5; // offset char *p1 = p0 + i; // 1-5 char *p2 = p1 + i; // 2-5 @@ -91,7 +91,7 @@ void warn_int_anti_range (int i) char *p4 = p3 + i; // 4-5 char *p5 = p4 + i; // 5 - memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size 0" "pr?????" { xfail *-*-* } } + memset (p5, 0, 5); // { dg-warning "writing 5 bytes into a region of size" "pr?????" } sink (p0, p1, p2, p3, p4, p5); } diff --git a/gcc/testsuite/gcc.dg/pr80776-1.c b/gcc/testsuite/gcc.dg/pr80776-1.c index af41c0c2ffa..f3a120b6744 100644 --- a/gcc/testsuite/gcc.dg/pr80776-1.c +++ b/gcc/testsuite/gcc.dg/pr80776-1.c @@ -17,7 +17,5 @@ Foo (void) __builtin_unreachable (); if (! (0 <= i && i <= 999999)) __builtin_unreachable (); - /* The correctness bits for [E]VRP cannot handle chained conditionals - when deciding to ignore a unreachable branch for setting SSA range info. */ - sprintf (number, "%d", i); /* { dg-bogus "writing" "" { xfail *-*-* } } */ + sprintf (number, "%d", i); /* { dg-bogus "writing" "" } */ } -- 2.31.1 --------------A512D68BF1D3910C8438F9D6--