From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 67ADC3830800 for ; Tue, 12 Jul 2022 01:48:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 67ADC3830800 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B268B116A3E; Mon, 11 Jul 2022 21:48:16 -0400 (EDT) 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 sPZbOLK8wBBn; Mon, 11 Jul 2022 21:48:16 -0400 (EDT) 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 E9F7611673C; Mon, 11 Jul 2022 21:48:15 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 26C1luK31321757 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Jul 2022 22:48:01 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka , Uros Bizjak , Rainer Orth , Mike Stump Subject: [PATCH] i386 testsuite: cope with --enable-default-pie Organization: Free thinker, does not speak for AdaCore Errors-To: aoliva@lxoliva.fsfla.org Date: Mon, 11 Jul 2022 22:47:56 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Tue, 12 Jul 2022 01:48:21 -0000 Running the testsuite on a toolchain build with --enable-default-pie had some unexpected fails. Adjust the tests to tolerate the effects of this configuration option on x86_64-linux-gnu and i686-linux-gnu. The cet-sjlj* tests get offsets before the base symbol name with PIC or PIE. A single pattern covering both alternatives somehow triggered two matches rather than the single expected match, thus my narrowing the '.*' to not skip line breaks, but that was not enough. Still puzzled, I separated the patterns into nonpic and !nonpic, and we get the expected matchcounts this way. Tests for -mfentry require an mfentry effective target, which excludes 32-bit x86 with PIC or PIE enabled, that's why the patterns that accept the PIC sym@RELOC annotations only cover x86_64. The pr24414 test stores in an unadorned named variable in an old-style asm statement, to check that such asm statements get an implicit memory clobber. Rewriting the asm into a GCC extended asm with the variable as an output would remove the regression it checks against. Problem is, the literal reference to the variable is not PIC, so it's rejected by the elf64 linker with an error, and flagged with a warning by the elf32 one. We could presumably make the variable references PIC-friendly with #ifdefs, but I doubt that's worth the trouble. I'm just arranging for the test to be skipped if PIC or PIE are enabled by default. Regstrapped on x86_64-linux-gnu, and also tested on i686-linux-gnu, with and without --enable-default-pie on both platforms. Ok to install? PS: There's at least one additional FAIL with --enable-default-pie in the trunk, namely gcc.target/i386/mvc7.c, compared with the build without default PIE, but I believe that's out of scope for my current project. I could sneak in a fix for it if just rerunning this specific testcase is enough; rerunning all the tests over it, not so much. At the end of the patch is the patchlet that enables this one test to also pass on all 4 test combinations. WDYT? for gcc/testsuite/ChangeLog * gcc.target/i386/cet-sjlj-6a.c: Cope with --enable-default-pie. * gcc.target/i386/cet-sjlj-6b.c: Likewise. * gcc.target/i386/fentryname3.c: Likewise. * gcc.target/i386/pr24414.c: Likewise. * gcc.target/i386/pr93492-3.c: Likewise. * gcc.target/i386/pr93492-5.c: Likewise. * gcc.target/i386/pr98482-1.c: Likewise. --- gcc/testsuite/gcc.target/i386/cet-sjlj-6a.c | 6 ++++-- gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c | 6 ++++-- gcc/testsuite/gcc.target/i386/fentryname3.c | 3 ++- gcc/testsuite/gcc.target/i386/pr24414.c | 1 + gcc/testsuite/gcc.target/i386/pr93492-3.c | 2 +- gcc/testsuite/gcc.target/i386/pr93492-5.c | 2 +- gcc/testsuite/gcc.target/i386/pr98482-1.c | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-6a.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-6a.c index 040b297aeb023..c3d0eb929424d 100644 --- a/gcc/testsuite/gcc.target/i386/cet-sjlj-6a.c +++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-6a.c @@ -2,8 +2,10 @@ /* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O -maddress-mode=short -fcf-protection -mx32" } */ /* { dg-final { scan-assembler-times "endbr64" 2 } } */ -/* { dg-final { scan-assembler-times "movq\t.*buf\\+8" 1 } } */ -/* { dg-final { scan-assembler-times "subq\tbuf\\+8" 1 } } */ +/* { dg-final { scan-assembler-times "movq\t\[^\n\]*buf\\+8" 1 { target nonpic } } } */ +/* { dg-final { scan-assembler-times "movq\t\[^\n\]*8\\+buf" 1 { target { ! nonpic } } } } */ +/* { dg-final { scan-assembler-times "subq\tbuf\\+8" 1 { target nonpic } } } */ +/* { dg-final { scan-assembler-times "subq\t8\\+buf" 1 { target { ! nonpic } } } } */ /* { dg-final { scan-assembler-times "shrl\t\\\$3," 1 } } */ /* { dg-final { scan-assembler-times "rdsspq" 2 } } */ /* { dg-final { scan-assembler-times "incsspq" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c b/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c index b2376e710df6a..4c52685d7d1e1 100644 --- a/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c +++ b/gcc/testsuite/gcc.target/i386/cet-sjlj-6b.c @@ -2,8 +2,10 @@ /* { dg-require-effective-target maybe_x32 } */ /* { dg-options "-O -maddress-mode=long -fcf-protection -mx32" } */ /* { dg-final { scan-assembler-times "endbr64" 2 } } */ -/* { dg-final { scan-assembler-times "movq\t.*buf\\+16" 1 } } */ -/* { dg-final { scan-assembler-times "subq\tbuf\\+16" 1 } } */ +/* { dg-final { scan-assembler-times "movq\t\[^\n\]*buf\\+16" 1 { target nonpic } } } */ +/* { dg-final { scan-assembler-times "movq\t\[^\n\]*16\\+buf" 1 { target { ! nonpic } } } } */ +/* { dg-final { scan-assembler-times "subq\tbuf\\+16" 1 { target nonpic } } } */ +/* { dg-final { scan-assembler-times "subq\t16\\+buf" 1 { target { ! nonpic } } } } */ /* { dg-final { scan-assembler-times "shrl\t\\\$3," 1 } } */ /* { dg-final { scan-assembler-times "rdsspq" 2 } } */ /* { dg-final { scan-assembler-times "incsspq" 2 } } */ diff --git a/gcc/testsuite/gcc.target/i386/fentryname3.c b/gcc/testsuite/gcc.target/i386/fentryname3.c index bd7c997c178f0..c14a4ebb0cf57 100644 --- a/gcc/testsuite/gcc.target/i386/fentryname3.c +++ b/gcc/testsuite/gcc.target/i386/fentryname3.c @@ -3,7 +3,8 @@ /* { dg-require-profiling "-pg" } */ /* { dg-options "-pg -mfentry" } */ /* { dg-final { scan-assembler "section.*__entry_loc" } } */ -/* { dg-final { scan-assembler "0x0f, 0x1f, 0x44, 0x00, 0x00" } } */ +/* { dg-final { scan-assembler "0x0f, 0x1f, 0x44, 0x00, 0x00" { target nonpic } } } */ +/* { dg-final { scan-assembler "call\t\\*nop@GOTPCREL" { target { ! nonpic } } } } */ /* { dg-final { scan-assembler-not "__fentry__" } } */ __attribute__((fentry_name("nop"), fentry_section("__entry_loc"))) diff --git a/gcc/testsuite/gcc.target/i386/pr24414.c b/gcc/testsuite/gcc.target/i386/pr24414.c index 0acaa001a5c8a..6f77fa93cf0ac 100644 --- a/gcc/testsuite/gcc.target/i386/pr24414.c +++ b/gcc/testsuite/gcc.target/i386/pr24414.c @@ -1,4 +1,5 @@ /* { dg-do run } */ +/* { dg-require-effective-target nonpic } */ /* { dg-options "-O2" } */ /* { dg-skip-if "asm insert mismatches ABI for Darwin" { *-*-darwin* } } */ int test; diff --git a/gcc/testsuite/gcc.target/i386/pr93492-3.c b/gcc/testsuite/gcc.target/i386/pr93492-3.c index 52a19e5151362..a625c927f4f0b 100644 --- a/gcc/testsuite/gcc.target/i386/pr93492-3.c +++ b/gcc/testsuite/gcc.target/i386/pr93492-3.c @@ -10,4 +10,4 @@ f10_endbr (void) { } -/* { dg-final { scan-assembler "\t\.cfi_startproc\n\tendbr(32|64)\n.*\.LPFE1:\n\tnop\n1:\tcall\t__fentry__\n\tret\n" } } */ +/* { dg-final { scan-assembler "\t\.cfi_startproc\n\tendbr(32|64)\n.*\.LPFE1:\n\tnop\n1:\tcall\t\[^\n\]*__fentry__\[^\n\]*\n\tret\n" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr93492-5.c b/gcc/testsuite/gcc.target/i386/pr93492-5.c index fcf4ad43aa206..5aebb3847f5be 100644 --- a/gcc/testsuite/gcc.target/i386/pr93492-5.c +++ b/gcc/testsuite/gcc.target/i386/pr93492-5.c @@ -8,4 +8,4 @@ foo (void) { } -/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n1:\tcall\t__fentry__\n\tret\n" } } */ +/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n1:\tcall\t\[^\n\]*__fentry__\[^\n\]*\n\tret\n" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr98482-1.c b/gcc/testsuite/gcc.target/i386/pr98482-1.c index 912cbe0919100..b1d9619275e72 100644 --- a/gcc/testsuite/gcc.target/i386/pr98482-1.c +++ b/gcc/testsuite/gcc.target/i386/pr98482-1.c @@ -1,7 +1,8 @@ /* { dg-do compile { target { *-*-linux* && lp64 } } } */ /* { dg-require-effective-target mfentry } */ /* { dg-options "-fprofile -mfentry -O2 -mcmodel=large" } */ -/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__, %r10\n\tcall\t\\*%r10" } } */ +/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__, %r10\n\tcall\t\\*%r10" { target nonpic } } } */ +/* { dg-final { scan-assembler "movabsq\t\\\$__fentry__@PLTOFF, %r11\n\taddq\t%r11, %r10\n\tcall\t\\*%r10" { target { ! nonpic } } } } */ void func (void) for gcc/testsuite/ChangeLog * gcc.target/i386/mvc7.c: Likewise. Cover all variants with full-name matches. diff --git a/gcc/testsuite/gcc.target/i386/mvc7.c b/gcc/testsuite/gcc.target/i386/mvc7.c index 7fb9dded849a5..872cd5975ad34 100644 --- a/gcc/testsuite/gcc.target/i386/mvc7.c +++ b/gcc/testsuite/gcc.target/i386/mvc7.c @@ -2,12 +2,12 @@ /* { dg-require-ifunc "" } */ /* Verify that foo clones are not numbered. */ -/* { dg-final { scan-assembler "foo.resolver," } } */ -/* { dg-final { scan-assembler "foo.default," } } */ -/* { dg-final { scan-assembler "foo.avx," } } */ - -/* { dg-final { scan-assembler "slm" } } */ -/* { dg-final { scan-assembler "foo,foo.resolver" } } */ +/* { dg-final { scan-assembler "foo\.resolver," } } */ +/* { dg-final { scan-assembler "foo\.default\[,@\]" } } */ +/* { dg-final { scan-assembler "foo\.avx\[,@\]" } } */ +/* { dg-final { scan-assembler "foo\.arch_core_avx2\[,@\]" } } */ +/* { dg-final { scan-assembler "foo\.arch_slm\[,@\]" } } */ +/* { dg-final { scan-assembler "foo,foo\.resolver" } } */ __attribute__((target_clones("avx","default","arch=slm","arch=core-avx2"))) int foo (); -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer Disinformation flourishes because many people care deeply about injustice but very few check the facts. Ask me about