From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 839843858D35 for ; Fri, 5 Nov 2021 09:43:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 839843858D35 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 B95E121892; Fri, 5 Nov 2021 09:43:38 +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 A46FD13B97; Fri, 5 Nov 2021 09:43:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UpskJsr8hGGbbQAAMHmgww (envelope-from ); Fri, 05 Nov 2021 09:43:38 +0000 Subject: Re: [PATCH] [gdb/testsuite] Fix gdb.arch/i386-avx.exp with clang To: Andrew Burgess Cc: gdb-patches@sourceware.org References: <20211104135559.5875-1-tdevries@suse.de> <20211105093300.GG918204@redhat.com> From: Tom de Vries Message-ID: Date: Fri, 5 Nov 2021 10:43:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20211105093300.GG918204@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, 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: 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: , X-List-Received-Date: Fri, 05 Nov 2021 09:43:41 -0000 On 11/5/21 10:33 AM, Andrew Burgess wrote: > * Tom de Vries via Gdb-patches [2021-11-04 14:55:59 +0100]: > >> 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[] = > > I see the same problem. Did you consider using: > > /* Some useful comment .... */ > v8sf_t data[] __attribute__ ((aligned(32))) = .... > > this seems to fix the problem on clang for me, and still works fine > with gcc. I did consider this, and decided against it because it's not portable. Note btw that there is no other usage of this: ... $ find gdb/testsuite/ -type f | xargs grep attribute.*align $ ... Btw, I now realize that gdb.arch/i386-sse.exp has the same issue, I'll try to factor out a solution that can used in both test-cases. Thanks, - Tom