tighten funcspec regexps

Message ID orsg4lavsv.fsf@lxoliva.fsfla.org
State New
Headers show
Series
  • tighten funcspec regexps
Related show

Commit Message

Alexandre Oliva March 24, 2021, 6:51 a.m.
In -mcmodel=large, callee symbols are pulled ahead of the call insns.

The patterns in funcspec-[12].c tests in gcc.target/i386 match even
line breaks between 'call' and a function symbol expected to be
called, however, so it ends up unexpectedly matching a previous,
unrelated indirect call, up to the insn that loads the address of the
intended callee to a register, for all but the first callee, that
doesn't have a call insn before it.

All of these apparent passes are false positives.  We are NOT
generating the expected call insns.

This patch fixes only the patterns, so that they won't trigger false
positives any more.  There are several dozens of other tests that fail
with -mcmodel=large for similar reasons, but I'm still not sure about
how to deal with them.  I see no point in holding up this small
improvement over the lack of a larger solution of a different problem,
though.

Regstrapped on x86_64-linux-gnu and cross-tested for x86_64-vx7r2 along
with other patches, mostly for the testsuite.  Ok to install?


for  gcc/testsuite/ChangeLog

	* gcc.target/i386/funcspec-2.c: Tighten regexps to avoid false
	positives with -mcmodel=large.
	* gcc.target/i386/funcspec-3.c: Likewise.
---
 gcc/testsuite/gcc.target/i386/funcspec-2.c |   16 ++++++++--------
 gcc/testsuite/gcc.target/i386/funcspec-3.c |    6 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)



-- 
Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/
   Free Software Activist         GNU Toolchain Engineer
        Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

Comments

Martin Sebor via Gcc-patches March 24, 2021, 6:55 a.m. | #1
On Wed, Mar 24, 2021 at 7:51 AM Alexandre Oliva <oliva@adacore.com> wrote:
>

>

> In -mcmodel=large, callee symbols are pulled ahead of the call insns.

>

> The patterns in funcspec-[12].c tests in gcc.target/i386 match even

> line breaks between 'call' and a function symbol expected to be

> called, however, so it ends up unexpectedly matching a previous,

> unrelated indirect call, up to the insn that loads the address of the

> intended callee to a register, for all but the first callee, that

> doesn't have a call insn before it.

>

> All of these apparent passes are false positives.  We are NOT

> generating the expected call insns.

>

> This patch fixes only the patterns, so that they won't trigger false

> positives any more.  There are several dozens of other tests that fail

> with -mcmodel=large for similar reasons, but I'm still not sure about

> how to deal with them.  I see no point in holding up this small

> improvement over the lack of a larger solution of a different problem,

> though.

>

> Regstrapped on x86_64-linux-gnu and cross-tested for x86_64-vx7r2 along

> with other patches, mostly for the testsuite.  Ok to install?

>

>

> for  gcc/testsuite/ChangeLog

>

>         * gcc.target/i386/funcspec-2.c: Tighten regexps to avoid false

>         positives with -mcmodel=large.

>         * gcc.target/i386/funcspec-3.c: Likewise.


OK.

Thanks,
Uros.

> ---

>  gcc/testsuite/gcc.target/i386/funcspec-2.c |   16 ++++++++--------

>  gcc/testsuite/gcc.target/i386/funcspec-3.c |    6 +++---

>  2 files changed, 11 insertions(+), 11 deletions(-)

>

> diff --git a/gcc/testsuite/gcc.target/i386/funcspec-2.c b/gcc/testsuite/gcc.target/i386/funcspec-2.c

> index d607fbc79c91d..147f62321fd77 100644

> --- a/gcc/testsuite/gcc.target/i386/funcspec-2.c

> +++ b/gcc/testsuite/gcc.target/i386/funcspec-2.c

> @@ -89,11 +89,11 @@ int main ()

>  /* { dg-final { scan-assembler "vfnmaddsd" } } */

>  /* { dg-final { scan-assembler "vfnmsubss" } } */

>  /* { dg-final { scan-assembler "vfnmsubsd" } } */

> -/* { dg-final { scan-assembler "call\t(.*)flt_mul_add" } } */

> -/* { dg-final { scan-assembler "call\t(.*)flt_mul_sub" } } */

> -/* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_add" } } */

> -/* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_sub" } } */

> -/* { dg-final { scan-assembler "call\t(.*)dbl_mul_add" } } */

> -/* { dg-final { scan-assembler "call\t(.*)dbl_mul_sub" } } */

> -/* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_add" } } */

> -/* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_sub" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_mul_add" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_mul_sub" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_neg_mul_add" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_neg_mul_sub" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_mul_add" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_mul_sub" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_neg_mul_add" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_neg_mul_sub" } } */

> diff --git a/gcc/testsuite/gcc.target/i386/funcspec-3.c b/gcc/testsuite/gcc.target/i386/funcspec-3.c

> index 613a1a0fb9521..8fb425b925add 100644

> --- a/gcc/testsuite/gcc.target/i386/funcspec-3.c

> +++ b/gcc/testsuite/gcc.target/i386/funcspec-3.c

> @@ -63,6 +63,6 @@ int main ()

>  /* { dg-final { scan-assembler "popcntl" { target { ! *-*-darwin* } } } } */

>  /* { dg-final { scan-assembler "popcntq" { target { ! *-*-darwin* } } } } */

>  /* { dg-final { scan-assembler-times "popcnt" 2 { target *-*-darwin* } } } */

> -/* { dg-final { scan-assembler "call\t(.*)sse4a_pop_i" } } */

> -/* { dg-final { scan-assembler "call\t(.*)sse42_pop_l" } } */

> -/* { dg-final { scan-assembler "call\t(.*)popcountdi2" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)sse4a_pop_i" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)sse42_pop_l" } } */

> +/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)popcountdi2" } } */

>

>

> --

> Alexandre Oliva, happy hacker  https://FSFLA.org/blogs/lxo/

>    Free Software Activist         GNU Toolchain Engineer

>         Vim, Vi, Voltei pro Emacs -- GNUlius Caesar

Patch

diff --git a/gcc/testsuite/gcc.target/i386/funcspec-2.c b/gcc/testsuite/gcc.target/i386/funcspec-2.c
index d607fbc79c91d..147f62321fd77 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-2.c
+++ b/gcc/testsuite/gcc.target/i386/funcspec-2.c
@@ -89,11 +89,11 @@  int main ()
 /* { dg-final { scan-assembler "vfnmaddsd" } } */
 /* { dg-final { scan-assembler "vfnmsubss" } } */
 /* { dg-final { scan-assembler "vfnmsubsd" } } */
-/* { dg-final { scan-assembler "call\t(.*)flt_mul_add" } } */
-/* { dg-final { scan-assembler "call\t(.*)flt_mul_sub" } } */
-/* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_add" } } */
-/* { dg-final { scan-assembler "call\t(.*)flt_neg_mul_sub" } } */
-/* { dg-final { scan-assembler "call\t(.*)dbl_mul_add" } } */
-/* { dg-final { scan-assembler "call\t(.*)dbl_mul_sub" } } */
-/* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_add" } } */
-/* { dg-final { scan-assembler "call\t(.*)dbl_neg_mul_sub" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_mul_add" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_mul_sub" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_neg_mul_add" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)flt_neg_mul_sub" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_mul_add" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_mul_sub" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_neg_mul_add" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)dbl_neg_mul_sub" } } */
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-3.c b/gcc/testsuite/gcc.target/i386/funcspec-3.c
index 613a1a0fb9521..8fb425b925add 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-3.c
+++ b/gcc/testsuite/gcc.target/i386/funcspec-3.c
@@ -63,6 +63,6 @@  int main ()
 /* { dg-final { scan-assembler "popcntl" { target { ! *-*-darwin* } } } } */
 /* { dg-final { scan-assembler "popcntq" { target { ! *-*-darwin* } } } } */
 /* { dg-final { scan-assembler-times "popcnt" 2 { target *-*-darwin* } } } */
-/* { dg-final { scan-assembler "call\t(.*)sse4a_pop_i" } } */
-/* { dg-final { scan-assembler "call\t(.*)sse42_pop_l" } } */
-/* { dg-final { scan-assembler "call\t(.*)popcountdi2" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)sse4a_pop_i" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)sse42_pop_l" } } */
+/* { dg-final { scan-assembler "call\t(\[^\n\r\]*)popcountdi2" } } */