From patchwork Tue Dec 14 14:49:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 48899 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 84F9D3857C79 for ; Tue, 14 Dec 2021 14:49:43 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 1E6603858414 for ; Tue, 14 Dec 2021 14:49:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E6603858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E8D6421124 for ; Tue, 14 Dec 2021 14:49:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1639493348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kHwca5XLMdKCo4nctyZwSed7dcnIwwneJ6aYl0ywzWI=; b=ICU9QgQkkoPZpGDOl7kp1xpA36vSKPb4a+dmEb7U4nm1Qknz40s8ihnbuGpQZ3HEnrwKHw tsK6/6b5WqC08tKzt0bI9zWiYFa1imTLziLsWQMDIc0U8i1O/vau/YpFI3WvfGJfRVggTF dFwrMVW9x6tuAk9gilLmZ9A1KLx2R2o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1639493348; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kHwca5XLMdKCo4nctyZwSed7dcnIwwneJ6aYl0ywzWI=; b=v3DZQPy8/XngCOlns3mzYnSp0KFDB+mM2NtRRb2S+4BEn9GO4NgNhGze5Qt08atEgYZBJH Zn2WUNNkj/MMFKAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D192513DF1 for ; Tue, 14 Dec 2021 14:49:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id BTqhMeSuuGGMUgAAMHmgww (envelope-from ) for ; Tue, 14 Dec 2021 14:49:08 +0000 Message-ID: Date: Tue, 14 Dec 2021 15:49:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH][pushed] testsuite: fix ASAN errors To: gcc-patches@gcc.gnu.org Content-Language: en-US X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" The tests failed on my machine as they contain out-of-bounds access. I'm going to push the fix. Martin gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-psraq-1.c: Use ARRAY_SIZE. * gcc.target/i386/m128-check.h: Move it to the top-level context. * gcc.target/i386/sse2-psraq-1.c: Use ARRAY_SIZE. * gcc.target/i386/sse4_2-check.h: Include the header with ARRAY_SIZE definition. --- gcc/testsuite/gcc.target/i386/avx2-psraq-1.c | 2 +- gcc/testsuite/gcc.target/i386/m128-check.h | 8 ++++---- gcc/testsuite/gcc.target/i386/sse2-psraq-1.c | 2 +- gcc/testsuite/gcc.target/i386/sse4_2-check.h | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c b/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c index e9051bf9fcb..96e5c4ccf76 100644 --- a/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c +++ b/gcc/testsuite/gcc.target/i386/avx2-psraq-1.c @@ -41,7 +41,7 @@ TEST (void) V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL, 0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL }; int i; - for (i = 0; tests[i].n; i++) + for (i = 0; i < ARRAY_SIZE (tests); i++) { V c = tests[i].fn (a); if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n diff --git a/gcc/testsuite/gcc.target/i386/m128-check.h b/gcc/testsuite/gcc.target/i386/m128-check.h index c468eac6a13..e90e1f02d32 100644 --- a/gcc/testsuite/gcc.target/i386/m128-check.h +++ b/gcc/testsuite/gcc.target/i386/m128-check.h @@ -1,6 +1,10 @@ #include #include +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0])) +#endif + #ifdef __SSE2__ #include @@ -66,10 +70,6 @@ typedef union float a[4]; } union128; -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(A) (sizeof (A) / sizeof ((A)[0])) -#endif - #ifdef DEBUG #define PRINTF printf #else diff --git a/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c b/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c index 9a08ee4f7fa..dfb0bb8435f 100644 --- a/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c +++ b/gcc/testsuite/gcc.target/i386/sse2-psraq-1.c @@ -41,7 +41,7 @@ TEST (void) V a = (V) { 0xdeadbeefcafebabeULL, 0x123456789abcdef0ULL }; V b = (V) { 0x173a74be8a95134cULL, 0x817bae35ac0ebf12ULL }; int i; - for (i = 0; tests[i].n; i++) + for (i = 0; i < ARRAY_SIZE (tests); i++) { V c = tests[i].fn (a); if (c[0] != a[0] >> tests[i].n || c[1] != a[1] >> tests[i].n) diff --git a/gcc/testsuite/gcc.target/i386/sse4_2-check.h b/gcc/testsuite/gcc.target/i386/sse4_2-check.h index d10e6c7d7e2..c33cd1b4986 100644 --- a/gcc/testsuite/gcc.target/i386/sse4_2-check.h +++ b/gcc/testsuite/gcc.target/i386/sse4_2-check.h @@ -1,6 +1,7 @@ #include #include +#include "m128-check.h" #include "cpuid.h" static void sse4_2_test (void);