From patchwork Tue Sep 26 18:29:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1839890 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=Ry4OCEh2; 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 4Rw7ZP14yDz1ypD for ; Wed, 27 Sep 2023 04:29:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE3A6385CCA1 for ; Tue, 26 Sep 2023 18:29:45 +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 DFF30385B522 for ; Tue, 26 Sep 2023 18:29:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFF30385B522 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=1695752973; 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=tguAZpXj2gEdZkktORZRX9oLfCvoU5NOluS4mo2v2ak=; b=Ry4OCEh22FM9w3MMt5OnxgK1I/fq3eQIrAgSm5kYU/iu16Z2dq4NVhZGrwk/6oPgt68J8q kuddM7sMGoeyA75tXEDuP5J1OVAOd3MB1f6EpFWO9GneB8I1sc71tNArQ1qrIqknHNSHDN XCwxBj4x8JcTyvo4PJ4mUc3Bf8JLgDw= 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-155-rlSDe2SKMuCPha5DmIv1Pw-1; Tue, 26 Sep 2023 14:29:31 -0400 X-MC-Unique: rlSDe2SKMuCPha5DmIv1Pw-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7740517a478so1712913385a.3 for ; Tue, 26 Sep 2023 11:29:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695752970; x=1696357770; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VW2hy/B+FSMCChCQLfXwCk2+ERcLkRvD+QZjdRXgUJU=; b=lklTiwoz0vrr2wFdWtpupZua8e7XYJFsUar4kwzPWXU1UZDZQKe1LRJHy1tATWrJ7t ztxQAopv/f+sqqNHJ7+bl0TNLubIA+scS1jRkcL/MFrp546TsbFvGcpSo3fo9k8A+V0t CLS0kGp07jYKWd2KX7TsemYm/9muQyUaASic30TBYLnO0CM8MRzOqzkZ0L/v66L3jqmX rfuV7OOt6/8j0IeqzvSPAJgBZhkwRIsM/U0wLk1ov3R+jLfWnbwcH9DqH5IaanM3kZXq V32Q2K+iASFYa0jGDDJjlln4sZiU3j43+A9BCd3cM8hWo3+zeEPQgi+buvWT+Xld9ITn CX6Q== X-Gm-Message-State: AOJu0YwqRNvQoSpo3pMdk95pAJNlrD5I8fKv4uwzWMxQqTGIcwY67aI6 qGx+HAeyR30JKUuxj5f1WI/WDKrSTT6kHHXCRPNsj59uMKrauAx61DR9UbK7nViJPD54cIXC+/x CR/ybKc9HV3YIis2K41uyaV4Frb7OQYBEs2oSHf2qle3riKPYCQVCiRDqSNBp2d2RuMCAc2xVsY eN8w== X-Received: by 2002:a05:620a:430a:b0:774:1012:8220 with SMTP id u10-20020a05620a430a00b0077410128220mr12757394qko.23.1695752969955; Tue, 26 Sep 2023 11:29:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELHfEyOIxcdwvJ6I5xpiRM6IABLfkWdbKZMLxxJ36xgEfGJ4XPXeVyxgDtr2owXMOodd27BQ== X-Received: by 2002:a05:620a:430a:b0:774:1012:8220 with SMTP id u10-20020a05620a430a00b0077410128220mr12757376qko.23.1695752969657; Tue, 26 Sep 2023 11:29:29 -0700 (PDT) Received: from [192.168.0.174] ([104.219.124.252]) by smtp.gmail.com with ESMTPSA id oq15-20020a05620a610f00b0076dae4753efsm4923692qkn.14.2023.09.26.11.29.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Sep 2023 11:29:29 -0700 (PDT) Message-ID: <5411fa57-4faf-4b51-de95-db131f8cc364@redhat.com> Date: Tue, 26 Sep 2023 14:29:32 -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 Cc: "hernandez, aldy" From: Andrew MacLeod Subject: [COMMITTED] PR tree-optimization/111599 - Ensure ssa_name is still valid. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.4 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 When processing an equivalence list, I neglected to make sure the ssa-name is still valid.  This patch simply checks to make sure it non-null and not in the free-list. Bootstraps on x86_64-pc-linux-gnu with no regressions.   Pushed. Andrew From 9df0f6bd582ceee53bfed8769cf156329ae33bd0 Mon Sep 17 00:00:00 2001 From: Andrew MacLeod Date: Tue, 26 Sep 2023 09:27:52 -0400 Subject: [PATCH] Ensure ssa_name is still valid. When the IL changes, an equivalence set may contain ssa_names that no longer exist. Ensure names are still valid and not in the free list. PR tree-optimization/111599 gcc/ * value-relation.cc (relation_oracle::valid_equivs): Ensure ssa_name is valid. gcc/testsuite/ * gcc.dg/pr111599.c: New. --- gcc/testsuite/gcc.dg/pr111599.c | 16 ++++++++++++++++ gcc/value-relation.cc | 9 ++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr111599.c diff --git a/gcc/testsuite/gcc.dg/pr111599.c b/gcc/testsuite/gcc.dg/pr111599.c new file mode 100644 index 00000000000..25880b759f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr111599.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-inline-functions-called-once -fno-inline-small-functions -fno-tree-dce -fno-tree-forwprop -fno-tree-fre" } */ + +int h(void); +void l(int); +void func_56(int p_57, unsigned p_58) { + // p_57 = 0x101BC642L; + if (p_57 || h()) { + int *l_105[2]; + l_105[0] = &p_57; + l(p_57); + } +} +void func_31(int p_33) { + func_56(0x101BC642L, (p_33)); +} diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index f2c668a0193..8fea4aad345 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -274,9 +274,12 @@ relation_oracle::valid_equivs (bitmap b, const_bitmap equivs, basic_block bb) EXECUTE_IF_SET_IN_BITMAP (equivs, 0, i, bi) { tree ssa = ssa_name (i); - const_bitmap ssa_equiv = equiv_set (ssa, bb); - if (ssa_equiv == equivs) - bitmap_set_bit (b, i); + if (ssa && !SSA_NAME_IN_FREE_LIST (ssa)) + { + const_bitmap ssa_equiv = equiv_set (ssa, bb); + if (ssa_equiv == equivs) + bitmap_set_bit (b, i); + } } } -- 2.41.0