From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CQ/EDYXmg2HRbwAAWB0awg (envelope-from ) for ; Thu, 04 Nov 2021 09:56:21 -0400 Received: by simark.ca (Postfix, from userid 112) id 280921F0C1; Thu, 4 Nov 2021 09:56:21 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5C27C1E813 for ; Thu, 4 Nov 2021 09:56:20 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36D3C3857C5F for ; Thu, 4 Nov 2021 13:56:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36D3C3857C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636034179; bh=O9dB1W0jkZiWLqL2xVo5dvNnP6/9BToTaC1L98S4tGc=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=c+IFLmQqikA+4b/7JWDqH1cB0kbD/REMec+eq5Ug/3VC8qTKK/iFlVc8iso4D4JJO 6rrxYd45KtOw/CyTwKmUfrLBp5O/gzV5paB2Ze+MHfTc1Jf8rrPckbVtBQXfjtGvHI 3pSj83c7tILeLvnQyN2PR5+co6iJGgi01TkshTdY= Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id CF062385840B for ; Thu, 4 Nov 2021 13:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF062385840B 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 D2C83218B8 for ; Thu, 4 Nov 2021 13:55:59 +0000 (UTC) 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 C026D13BD9 for ; Thu, 4 Nov 2021 13:55:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 3mTBLW/mg2FOPQAAMHmgww (envelope-from ) for ; Thu, 04 Nov 2021 13:55:59 +0000 To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix gdb.arch/i386-avx.exp with clang Date: Thu, 4 Nov 2021 14:55:59 +0100 Message-Id: <20211104135559.5875-1-tdevries@suse.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" When running test-case gdb.arch/i386-avx.exp with clang I ran into: ... (gdb) PASS: gdb.arch/i386-avx.exp: set first breakpoint in main continue^M Continuing.^M ^M Program received signal SIGSEGV, Segmentation fault.^M 0x000000000040052b in main (argc=1, argv=0x7fffffffd3c8) at i386-avx.c:54^M 54 asm ("vmovaps 0(%0), %%ymm0\n\t"^M (gdb) FAIL: gdb.arch/i386-avx.exp: continue to breakpoint: \ continue to first breakpoint in main ... The problem is that the vmovaps insn requires an 256-bit (or 32-byte aligned address), and it's only 16-byte aligned: ... (gdb) p /x $rax $1 = 0x601030 ... Fix this by copying to a sufficiently aligned address. Tested on x86_64-linux, with both gcc and clang. --- gdb/testsuite/gdb.arch/i386-avx.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.arch/i386-avx.c b/gdb/testsuite/gdb.arch/i386-avx.c index 4e938399a24..9b5323f9f76 100644 --- a/gdb/testsuite/gdb.arch/i386-avx.c +++ b/gdb/testsuite/gdb.arch/i386-avx.c @@ -18,6 +18,9 @@ along with this program. If not, see . */ #include +#include +#include +#include #include "nat/x86-cpuid.h" typedef struct { @@ -25,7 +28,7 @@ typedef struct { } v8sf_t; -v8sf_t data[] = +v8sf_t data_orig[] = { { { 0.0, 0.125, 0.25, 0.375, 0.50, 0.625, 0.75, 0.875 } }, { { 1.0, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875 } }, @@ -47,10 +50,33 @@ v8sf_t data[] = #endif }; +float data_buf[sizeof (data_orig) * 2 / sizeof (float)]; int main (int argc, char **argv) { + v8sf_t *data; + + /* Initialize data pointer. */ + { + float *p = data_buf; + float *data_buf_end = &data_buf[sizeof (data_buf) / sizeof (*data_buf)]; + while (((uintptr_t)p & 0x1f) != 0 + && p < data_buf_end) + p++; + data = (v8sf_t *)p; + } + + /* Check that data pointer is sufficiently aligned to use vmovaps. */ + assert (((uintptr_t)data & 0x1f) == 0); + + /* Check that memcpy does not write out of bounds. */ + assert ((void *)data + sizeof (data_orig) + <= (void *)data_buf + sizeof (data_buf)); + + /* Initialize data contents. */ + memcpy (data, data_orig, sizeof (data_orig)); + asm ("vmovaps 0(%0), %%ymm0\n\t" "vmovaps 32(%0), %%ymm1\n\t" "vmovaps 64(%0), %%ymm2\n\t" base-commit: edc77c591add0a9c7740a9ed9f7e40358bf65dbf -- 2.26.2