From patchwork Tue Oct 3 14:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1842692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IU491rRn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S0Kz64mTwz1yph for ; Wed, 4 Oct 2023 01:32:18 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1DEB3870894 for ; Tue, 3 Oct 2023 14:32:15 +0000 (GMT) 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 [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E53273861C76 for ; Tue, 3 Oct 2023 14:32:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E53273861C76 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696343522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=rXYfIqetZqE+GZ1kpROMgC53nQTETnXp6eLXuB1ghxQ=; b=IU491rRnzA7Xxd28w1NGSNfP7DSzc0LjNdNJQCD5u+lfXaXhoRic0pWPUlxinkKyGr8qjq 9KOUqN+gkaN5tZXU5RZTrUjDU4mNDA+WsTaE+6s785NCakJZcj16sQ5H9X/xTCZVvQ8ixG Id2xD/XsM68+2qICR9NnjPbrW8T0+9s= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-lDvBpbgiOT2idBrlDNQoJg-1; Tue, 03 Oct 2023 10:32:01 -0400 X-MC-Unique: lDvBpbgiOT2idBrlDNQoJg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-775751c3437so133339085a.3 for ; Tue, 03 Oct 2023 07:32:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696343520; x=1696948320; h=cc:subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AsRtjEHLhszXPM8JFgadS6VQ84/VJfZ6dwvgfc+mR8o=; b=XkqrTfOzCjRSBwSFIHvPcAyFyX5CSGusVEBdwMqoj3aM3OfscU/FhpRTmymx3K/ic6 gRhjYG0BX47AmMRc+k0RweuOKOn5eisCFBsNjMkT57TppKqo1zaQgbU3c6QIZvIklMRh 1ozzCTkCQJZ2MnOCDQoL1YDNtYuxyv4KPyXVsvFOlQBZy2HBzRO0NeWbnWpRMF4qnTOn HS9dF7d91yJ4wcJG6nMGjhMKj+rzqo2LtSmZhzOAxITiDzuiyyn3+a9JETFndBJ+idwT u20HKiS2PmAfqKm86Z4tp04mYjU5/lGdxUmAnHZEXr0CtqchxlCTzvx8LAC6cnY3jnSy SjTw== X-Gm-Message-State: AOJu0YyrjxAeoYYI+UO/dfXfFC03okJlmf2ofN7CdWh5EoxpkLgD7Q5v yarOYXk90pFJpwLX42HUuLg9eTPndwuyOyfqe5c47jQ6B8Zd7qP8Sltsg5ftrGDLvFJbt7idFog 4gSy/Mk//FzzTwfXby+KtWNO7ipEmUSW4GuV+dCslEjcewQdZ736EN6Szu1JUkh0zQ7m6JpPzv8 Fd4w== X-Received: by 2002:ac8:7f55:0:b0:418:194a:f9fe with SMTP id g21-20020ac87f55000000b00418194af9femr18960250qtk.62.1696343520231; Tue, 03 Oct 2023 07:32:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEj4sbOiykQiSJfR5jdRIHcYg5q9JR1+qXP/vi6uB1MKTAq9YpuKO9QKR61QSmhstLuawaV8Q== X-Received: by 2002:ac8:7f55:0:b0:418:194a:f9fe with SMTP id g21-20020ac87f55000000b00418194af9femr18960229qtk.62.1696343519887; Tue, 03 Oct 2023 07:31:59 -0700 (PDT) Received: from [192.168.0.174] ([104.219.124.252]) by smtp.gmail.com with ESMTPSA id d26-20020ac8545a000000b004198f248e8dsm484083qtq.76.2023.10.03.07.31.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Oct 2023 07:31:59 -0700 (PDT) Message-ID: <248800ec-0e0e-6cae-5aaa-a9c69cd5f46a@redhat.com> Date: Tue, 3 Oct 2023 10:32:01 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: gcc-patches From: Andrew MacLeod Subject: [COMMITTED] Remove pass counting in VRP. Cc: dmalcolm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.6 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_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Pass counting in VRP is used to decide when to call early VRP, pass the flag to enable warnings, and when the final pass is. If you try to add additional passes, this becomes quite fragile. This patch simply chooses the pass based on the data pointer passed in, and remove the pass counter.   The first FULL VRP pass invokes the warning code, and the flag passed in now represents the FINAL pass of VRP.  There is no longer a global flag which, as it turns out, wasn't working well with the JIT compiler, but when undetected.  (Thanks to dmalcolm for helping me sort out what was going on there) Bootstraps  on x86_64-pc-linux-gnu with no regressions.   Pushed. Andrew From 29abc475a360ad14d5f692945f2805fba1fdc679 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Thu, 28 Sep 2023 09:19:32 -0400 Subject: [PATCH 2/5] Remove pass counting in VRP. Rather than using a pass count to decide which parameters are passed to VRP, makemit explicit. * passes.def (pass_vrp): Use parameter for final pass flag.. * tree-vrp.cc (vrp_pass_num): Remove. (run_warning_pass): New. (pass_vrp::my_pass): Remove. (pass_vrp::final_p): New. (pass_vrp::set_pass_param): Set final_p param. (pass_vrp::execute): Choose specific pass based on data pointer. --- gcc/passes.def | 4 ++-- gcc/tree-vrp.cc | 26 +++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/gcc/passes.def b/gcc/passes.def index 4110a472914..2bafd60bbfb 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -221,7 +221,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_fre, true /* may_iterate */); NEXT_PASS (pass_merge_phi); NEXT_PASS (pass_thread_jumps_full, /*first=*/true); - NEXT_PASS (pass_vrp, true /* warn_array_bounds_p */); + NEXT_PASS (pass_vrp, false /* final_p*/); NEXT_PASS (pass_dse); NEXT_PASS (pass_dce); /* pass_stdarg is always run and at this point we execute @@ -348,7 +348,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_dominator, false /* may_peel_loop_headers_p */); NEXT_PASS (pass_strlen); NEXT_PASS (pass_thread_jumps_full, /*first=*/false); - NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */); + NEXT_PASS (pass_vrp, true /* final_p */); /* Run CCP to compute alignment and nonzero bits. */ NEXT_PASS (pass_ccp, true /* nonzero_p */); NEXT_PASS (pass_warn_restrict); diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc index d7b194f5904..05266dfe34a 100644 --- a/gcc/tree-vrp.cc +++ b/gcc/tree-vrp.cc @@ -1120,36 +1120,44 @@ const pass_data pass_data_early_vrp = ( TODO_cleanup_cfg | TODO_update_ssa | TODO_verify_all ), }; -static int vrp_pass_num = 0; +static bool run_warning_pass = true; class pass_vrp : public gimple_opt_pass { public: pass_vrp (gcc::context *ctxt, const pass_data &data_) - : gimple_opt_pass (data_, ctxt), data (data_), warn_array_bounds_p (false), - my_pass (vrp_pass_num++) - {} + : gimple_opt_pass (data_, ctxt), data (data_), + warn_array_bounds_p (false), final_p (false) + { + // Only the frst VRP pass should run warnings. + if (&data == &pass_data_vrp) + { + warn_array_bounds_p = run_warning_pass; + run_warning_pass = false; + } + } /* opt_pass methods: */ opt_pass * clone () final override { return new pass_vrp (m_ctxt, data); } void set_pass_param (unsigned int n, bool param) final override { gcc_assert (n == 0); - warn_array_bounds_p = param; + final_p = param; } bool gate (function *) final override { return flag_tree_vrp != 0; } unsigned int execute (function *fun) final override { // Early VRP pass. - if (my_pass == 0) - return execute_ranger_vrp (fun, /*warn_array_bounds_p=*/false, false); + if (&data == &pass_data_early_vrp) + return execute_ranger_vrp (fun, /*warn_array_bounds_p=*/false, + /*final_p=*/false); - return execute_ranger_vrp (fun, warn_array_bounds_p, my_pass == 2); + return execute_ranger_vrp (fun, warn_array_bounds_p, final_p); } private: const pass_data &data; bool warn_array_bounds_p; - int my_pass; + bool final_p; }; // class pass_vrp const pass_data pass_data_assumptions = -- 2.41.0