From patchwork Sat Dec 3 08:15:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 29244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1264705wrr; Sat, 3 Dec 2022 00:16:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf61ZU3Bd0LUEFiofDwZ1EiT1JbUPNXescnU6rqE0Bt012hEnXZ5Bi2R6HWWvLvPMHFBrwJb X-Received: by 2002:a05:6402:538a:b0:458:fbd9:e3b1 with SMTP id ew10-20020a056402538a00b00458fbd9e3b1mr10648835edb.6.1670055380766; Sat, 03 Dec 2022 00:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670055380; cv=none; d=google.com; s=arc-20160816; b=CDLR8bt+8WPQeG63ftJlAcVViFbfFhZJWfEWDpbhqmWAZKOHkyxqUZg47+G2C0/S4q AdNxKuGHyVKZCq/zRwvJE1IfWZUxuY53zL5Kr0zcpPsGo2/oa+l/j+b7nyvF/EMTlw6p W1j/Q4sT0zyA/W9Nz/QHOUqieoHYaLpRbuQygRZmOn+fipIIIFQaD66t4PppMKXo2zVQ 11/rrIvHpHfBldE2j8CLnLEpG+UHe15Thr7nEd8GQzZe2QYAf5R4Y1iYXv+6xN1T5uiT jsxAyO1Ccty/pPnMya9XOz6yw82n5zQ3QxIRfyEUD9zC/iaH64JoElitdgL4zuk4RcEe dL4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:date:organization:subject:cc:to:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=FWbF8k4Ikcx29QXHzqKl2t1ReovEWgKdWVe6M0Pycnw=; b=cGdTv1zA8QCNRRGp3RtkZ0XFnB+lfKTLvWXzoiUEARaA3SjDpFpO54s1S+aYByFJ6C nGLSa0cBXrcHKkDGPB3p/S5DqbScBnolTsHCWGVZS/3tlVtXC1u0Oxk98cMzDwmbhYVJ pLhAtc/IbxYQqKtzqw4OGzv5uU0vpojb+XkTWITEfcJxFtN7T6BG75wSmMFci8p1Mj71 V+1duqJCP2KhEsAq2jxBD2bdRgjdEI2vN0UQXcD/Br+1K/GLaNuWhTWCn1fZOMI+udPf CUDG1B8QSd51nxUdUcQ51UXptINTKC4ItM/+RlP1zMd2NykYnpEpoOS15VYmh3neMpXi LYnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KFN8JhO2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f20-20020a50fc94000000b004588af9ea19si7611835edq.166.2022.12.03.00.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Dec 2022 00:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=KFN8JhO2; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BE413858C2D for ; Sat, 3 Dec 2022 08:16:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BE413858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670055379; bh=FWbF8k4Ikcx29QXHzqKl2t1ReovEWgKdWVe6M0Pycnw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=KFN8JhO2FubI9b/VE5djSGEx/pTuKXCbnybwFaFdpN28hqDtO0LjsguyD0RaXyOJ7 V61AgzIQH4yjnHQ1eGgd9r8mVFRrUXGWycFvuhQHENa8bb8v/sdyumvKlQIdAgX6UO aXr8eT0lVK4zmp9dy1sdGfvxRUJsLihJUhdoRuaY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 1BF883858D39; Sat, 3 Dec 2022 08:15:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1BF883858D39 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id F0C10116BD2; Sat, 3 Dec 2022 03:15:27 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 960krCZJn0LN; Sat, 3 Dec 2022 03:15:27 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id 6FE87116BC7; Sat, 3 Dec 2022 03:15:26 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 2B38FCm21318854 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 3 Dec 2022 05:15:13 -0300 To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Mike Stump , Martin Sebor , Hongtao Liu , Kewen Lin Subject: [PATCH] [PR102706] [testsuite] -Wno-stringop-overflow vs Warray-bounds Organization: Free thinker, does not speak for AdaCore Date: Sat, 03 Dec 2022 05:15:11 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alexandre Oliva via Gcc-patches From: Alexandre Oliva Reply-To: Alexandre Oliva Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751179991149900684?= X-GMAIL-MSGID: =?utf-8?q?1751179991149900684?= The bogus Wstringop-overflow warnings conditionally issued for Warray-bounds-48.c and -Wzero-length-array-bounds-2.c are expected under conditions that depend on the availability of certain vector patterns, but that don't take cost analysis into account, which leads to omitted expected warnings and to unexpected warnings. On riscv64-elf and arm-eabi/-mcpu=cortex-r5, for example, though the Warray-bounds-48.c condition passes, we don't issue warnings because we decide not to vectorize the assignments. On riscv64, for Wzero-length-array-bounds-2.c, we issue the expected warning in test_C_global_buf, but we also issue a warning for test_C_local_buf under the same conditions, that would be expected on other platforms but that is not issued on them. On arm-eabi/-mcpu=cortex-r5, the condition passes so we'd expect the warning in both functions, but we don't warn on either. Instead of further extending the effective target tests, introduced to temporarily tolerate these expected bogus warnings, so as to capture the cost analyses that lead to the mismatched decisions, I'm disabling the undesired warnings for these two tests. Regstrapping on x86_64-linux-gnu, also tested with crosses to riscv64-elf and arm-eabi. Ok to install? for gcc/testsuite/ChangeLog PR tree-optimization/102706 * gcc.dg/Warray-bounds-48.c: Disable -Wstringop-overflow. * gcc.dg/Wzero-length-array-bounds-2.c: Likewise. --- gcc/testsuite/gcc.dg/Warray-bounds-48.c | 11 +++++++++-- gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-48.c b/gcc/testsuite/gcc.dg/Warray-bounds-48.c index 775b301e37537..e9203140a274a 100644 --- a/gcc/testsuite/gcc.dg/Warray-bounds-48.c +++ b/gcc/testsuite/gcc.dg/Warray-bounds-48.c @@ -4,6 +4,11 @@ { dg-options "-O2 -Wall" } { dg-require-effective-target alloca } */ +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and often + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + typedef __INT16_TYPE__ int16_t; typedef __INT32_TYPE__ int32_t; @@ -30,7 +35,8 @@ static void nowarn_ax_extern (struct AX *p) static void warn_ax_local_buf (struct AX *p) { - p->ax[0] = 4; p->ax[1] = 5; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } } + p->ax[0] = 4; p->ax[1] = 5; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } p->ax[2] = 6; // { dg-warning "\\\[-Warray-bounds" } p->ax[3] = 7; // { dg-warning "\\\[-Warray-bounds" } @@ -130,7 +136,8 @@ static void warn_a0_extern (struct A0 *p) static void warn_a0_local_buf (struct A0 *p) { - p->a0[0] = 4; p->a0[1] = 5; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } } + p->a0[0] = 4; p->a0[1] = 5; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2hi_store_align && { ! vect_slp_v4hi_store_unalign } } } p->a0[2] = 6; // { dg-warning "\\\[-Warray-bounds" } p->a0[3] = 7; // { dg-warning "\\\[-Warray-bounds" } diff --git a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c b/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c index 2ef5ccd564ac4..19932d05a315f 100644 --- a/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c +++ b/gcc/testsuite/gcc.dg/Wzero-length-array-bounds-2.c @@ -4,6 +4,11 @@ { dg-do compile } { dg-options "-O2 -Wall" } */ +/* pr102706: disabled warnings because the now-disabled conditions for the + bogus warnings to come up do not take cost analysis into account, and often + come up wrong. */ +/* { dg-additional-options "-Wno-stringop-overflow" } */ + void sink (void*); struct A { int i; }; @@ -87,7 +92,8 @@ void test_C_global_buf (void) p->b1.a[ 1].i = 0; // { dg-warning "\\\[-Wzero-length-bounds" } sink (p); - p->b2.a[ 0].i = 0; // { dg-warning "\\\[-Wstringop-overflow" "pr102706" { target { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unalign } } } } + p->b2.a[ 0].i = 0; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unalign } } } p->b2.a[ 1].i = 0; p->b2.a[ 2].i = 0; // { dg-warning "\\\[-Warray-bounds" } p->b2.a[ 3].i = 0; // { dg-warning "\\\[-Warray-bounds" } @@ -117,7 +123,8 @@ void test_C_local_buf (void) p->b1.a[ 1].i = 8; // { dg-warning "\\\[-Wzero-length-bounds" } sink (p); - p->b2.a[ 0].i = 9; + p->b2.a[ 0].i = 9; // { dg-bogus "\\\[-Wstringop-overflow" "pr102706" } + // { xfail { vect_slp_v2si_store_align && { ! vect_slp_v4si_store_unalign } } } p->b2.a[ 1].i = 10; p->b2.a[ 2].i = 11; // { dg-warning "\\\[-Warray-bounds" } p->b2.a[ 3].i = 12; // { dg-warning "\\\[-Warray-bounds" }