[4/4] testsuite,jit: Handle Darwin/Mach-O in assembler tests.

Message ID 20240113135718.57643-5-iain@sandoe.co.uk
State Unresolved
Headers
Series [1/4] testsuite, jit: test-alias-attribute.c requires alias support. |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Iain Sandoe Jan. 13, 2024, 1:57 p.m. UTC
  Several of the jit tests check for assembler-specific output
which differs on Mach-O from ELF.

This patch uses the facility to make the scans targer-dependent
and adds handling for darwin.

gcc/testsuite/ChangeLog:

	* jit.dg/test-always_inline-attribute.c: Handle Darwin in
	jit-verify-assembler-output.
	* jit.dg/test-noinline-attribute.c: Likewise.
	* jit.dg/test-setting-alignment.c: Likewise.
	* jit.dg/test-used-attribute.c: Likewise.
	* jit.dg/test-variable-attribute.c: Likewise.
	* jit.dg/test-weak-attribute.c: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
 gcc/testsuite/jit.dg/test-always_inline-attribute.c | 10 +++++++---
 gcc/testsuite/jit.dg/test-noinline-attribute.c      | 10 +++++++---
 gcc/testsuite/jit.dg/test-setting-alignment.c       |  3 ++-
 gcc/testsuite/jit.dg/test-used-attribute.c          | 10 +++++++---
 gcc/testsuite/jit.dg/test-variable-attribute.c      | 10 ++++++----
 gcc/testsuite/jit.dg/test-weak-attribute.c          |  3 ++-
 6 files changed, 31 insertions(+), 15 deletions(-)
  

Comments

David Malcolm Jan. 16, 2024, 7:52 p.m. UTC | #1
On Sat, 2024-01-13 at 13:57 +0000, Iain Sandoe wrote:
> Several of the jit tests check for assembler-specific output
> which differs on Mach-O from ELF.
> 
> This patch uses the facility to make the scans targer-dependent
> and adds handling for darwin.

Sorry about the issues with the tests.

Thanks for the patch.  I wonder if there's a better way to express ELF
vs Mach-O, and if these tests should really be rewritten to e.g. use
dumpfiles from an earlier point in the optimizer where the results
might be less target-specific.

In the meantime, LGTM for trunk, assuming your testing was successful.

Thanks again for the patch
Dave


> 
> gcc/testsuite/ChangeLog:
> 
>         * jit.dg/test-always_inline-attribute.c: Handle Darwin in
>         jit-verify-assembler-output.
>         * jit.dg/test-noinline-attribute.c: Likewise.
>         * jit.dg/test-setting-alignment.c: Likewise.
>         * jit.dg/test-used-attribute.c: Likewise.
>         * jit.dg/test-variable-attribute.c: Likewise.
>         * jit.dg/test-weak-attribute.c: Likewise.
> 
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
>  gcc/testsuite/jit.dg/test-always_inline-attribute.c | 10 +++++++---
>  gcc/testsuite/jit.dg/test-noinline-attribute.c      | 10 +++++++---
>  gcc/testsuite/jit.dg/test-setting-alignment.c       |  3 ++-
>  gcc/testsuite/jit.dg/test-used-attribute.c          | 10 +++++++---
>  gcc/testsuite/jit.dg/test-variable-attribute.c      | 10 ++++++----
>  gcc/testsuite/jit.dg/test-weak-attribute.c          |  3 ++-
>  6 files changed, 31 insertions(+), 15 deletions(-)
> 
> diff --git a/gcc/testsuite/jit.dg/test-always_inline-attribute.c
> b/gcc/testsuite/jit.dg/test-always_inline-attribute.c
> index 5c3f386663f..f7201a17140 100644
> --- a/gcc/testsuite/jit.dg/test-always_inline-attribute.c
> +++ b/gcc/testsuite/jit.dg/test-always_inline-attribute.c
> @@ -148,6 +148,10 @@ int foo () {
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
>  /* Check that the "removed" function was inlined, but not the others
> */
> -/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" } } */
> +/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed,\\s+@function" { target { ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed,\\s+@function" { target { ! *-*-darwin* } } } }
> */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
> +
> +/* { dg-final { jit-verify-assembler-output-not "\\n_removed:" {
> target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output "\\n_not_removed:" {
> target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-
> darwin* } } } */
> diff --git a/gcc/testsuite/jit.dg/test-noinline-attribute.c
> b/gcc/testsuite/jit.dg/test-noinline-attribute.c
> index eac6cae6b6a..acfea8fc55e 100644
> --- a/gcc/testsuite/jit.dg/test-noinline-attribute.c
> +++ b/gcc/testsuite/jit.dg/test-noinline-attribute.c
> @@ -114,6 +114,10 @@ int foo () {
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
>  /* Check that the "removed" function was inlined, but not the others
> */
> -/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed.isra.0,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed.isra.0,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" } } */
> +/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed.isra.0,\\s+@function" { target { ! *-*-darwin* } }
> } } */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed.isra.0,\\s+@function" { target { ! *-*-darwin*
> } } } } */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
> +
> +/* { dg-final { jit-verify-assembler-output-not
> "\\n_removed.isra.0:" { target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output
> "\\n_not_removed.isra.0:" { target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-
> darwin* } } } */
> diff --git a/gcc/testsuite/jit.dg/test-setting-alignment.c
> b/gcc/testsuite/jit.dg/test-setting-alignment.c
> index 8489df9c6b9..14edc723f61 100644
> --- a/gcc/testsuite/jit.dg/test-setting-alignment.c
> +++ b/gcc/testsuite/jit.dg/test-setting-alignment.c
> @@ -62,5 +62,6 @@ create_code (gcc_jit_context *ctxt, void
> *user_data)
>  }
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
> -/* { dg-final { jit-verify-assembler-output ".comm     foo,4,8" } }
> */
> +/* { dg-final { jit-verify-assembler-output ".comm     foo,4,8" {
> target { ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output ".comm\\s_foo,4,3" {
> target *-*-darwin* } } } */
>  /* { dg-final { jit-verify-assembler-output "movl      -
> 16\\\(%rbp\\\), %eax" } } */
> diff --git a/gcc/testsuite/jit.dg/test-used-attribute.c
> b/gcc/testsuite/jit.dg/test-used-attribute.c
> index cb20952c687..446c5c5c31b 100644
> --- a/gcc/testsuite/jit.dg/test-used-attribute.c
> +++ b/gcc/testsuite/jit.dg/test-used-attribute.c
> @@ -107,6 +107,10 @@ int foo() {
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
>  /* Check that the "removed" function was inlined, but not the others
> */
> -/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed,\\s+@function" } } */
> -/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" } } */
> +/* { dg-final { jit-verify-assembler-output-not
> ".type\\s+removed,\\s+@function" { target { ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+not_removed,\\s+@function" { target { ! *-*-darwin* } } } }
> */
> +/* { dg-final { jit-verify-assembler-output
> ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
> +
> +/* { dg-final { jit-verify-assembler-output-not "\\n_removed:" {
> target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output "\\n_not_removed:" {
> target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-
> darwin* } } } */
> diff --git a/gcc/testsuite/jit.dg/test-variable-attribute.c
> b/gcc/testsuite/jit.dg/test-variable-attribute.c
> index ea854ff4a9f..219a47d8817 100644
> --- a/gcc/testsuite/jit.dg/test-variable-attribute.c
> +++ b/gcc/testsuite/jit.dg/test-variable-attribute.c
> @@ -40,7 +40,9 @@ int PUBLIC = 12;
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
>  /* Check that the attribute was applied correctly */
> -/* { dg-final { jit-verify-assembler-output ".hidden\\s+PRIVATE" } }
> */
> -/* { dg-final { jit-verify-assembler-output ".globl\\s+PRIVATE" } }
> */
> -/* { dg-final { jit-verify-assembler-output-not ".hidden\\s+PUBLIC"
> } } */
> -/* { dg-final { jit-verify-assembler-output ".globl\\s+PUBLIC" } }
> */
> +/* { dg-final { jit-verify-assembler-output ".hidden\\s+PRIVATE" {
> target { ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output
> ".private_extern\\s+_PRIVATE" { target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output ".globl\\s+_?PRIVATE" }
> } */
> +/* { dg-final { jit-verify-assembler-output-not ".hidden\\s+PUBLIC"
> { target { ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output-not
> ".private_extern\\s+_PUBLIC" { target *-*-darwin* } } } */
> +/* { dg-final { jit-verify-assembler-output ".globl\\s+_?PUBLIC" } }
> */
> diff --git a/gcc/testsuite/jit.dg/test-weak-attribute.c
> b/gcc/testsuite/jit.dg/test-weak-attribute.c
> index 546ade1c3c4..3ca9485bf41 100644
> --- a/gcc/testsuite/jit.dg/test-weak-attribute.c
> +++ b/gcc/testsuite/jit.dg/test-weak-attribute.c
> @@ -38,4 +38,5 @@ void f () {}
>  
>  /* { dg-final { jit-verify-output-file-was-created "" } } */
>  /* Check that the attribute was applied correctly */
> -/* { dg-final { jit-verify-assembler-output ".weak\\s+f" } } */
> +/* { dg-final { jit-verify-assembler-output ".weak\\s+f" { target {
> ! *-*-darwin* } } } } */
> +/* { dg-final { jit-verify-assembler-output ".weak_definition\\s+_f"
> { target *-*-darwin* } } } */
  

Patch

diff --git a/gcc/testsuite/jit.dg/test-always_inline-attribute.c b/gcc/testsuite/jit.dg/test-always_inline-attribute.c
index 5c3f386663f..f7201a17140 100644
--- a/gcc/testsuite/jit.dg/test-always_inline-attribute.c
+++ b/gcc/testsuite/jit.dg/test-always_inline-attribute.c
@@ -148,6 +148,10 @@  int foo () {
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
 /* Check that the "removed" function was inlined, but not the others */
-/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" } } */
+/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
+
+/* { dg-final { jit-verify-assembler-output-not "\\n_removed:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_not_removed:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-darwin* } } } */
diff --git a/gcc/testsuite/jit.dg/test-noinline-attribute.c b/gcc/testsuite/jit.dg/test-noinline-attribute.c
index eac6cae6b6a..acfea8fc55e 100644
--- a/gcc/testsuite/jit.dg/test-noinline-attribute.c
+++ b/gcc/testsuite/jit.dg/test-noinline-attribute.c
@@ -114,6 +114,10 @@  int foo () {
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
 /* Check that the "removed" function was inlined, but not the others */
-/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed.isra.0,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed.isra.0,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" } } */
+/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed.isra.0,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed.isra.0,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
+
+/* { dg-final { jit-verify-assembler-output-not "\\n_removed.isra.0:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_not_removed.isra.0:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-darwin* } } } */
diff --git a/gcc/testsuite/jit.dg/test-setting-alignment.c b/gcc/testsuite/jit.dg/test-setting-alignment.c
index 8489df9c6b9..14edc723f61 100644
--- a/gcc/testsuite/jit.dg/test-setting-alignment.c
+++ b/gcc/testsuite/jit.dg/test-setting-alignment.c
@@ -62,5 +62,6 @@  create_code (gcc_jit_context *ctxt, void *user_data)
 }
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
-/* { dg-final { jit-verify-assembler-output ".comm	foo,4,8" } } */
+/* { dg-final { jit-verify-assembler-output ".comm	foo,4,8" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".comm\\s_foo,4,3" { target *-*-darwin* } } } */
 /* { dg-final { jit-verify-assembler-output "movl	-16\\\(%rbp\\\), %eax" } } */
diff --git a/gcc/testsuite/jit.dg/test-used-attribute.c b/gcc/testsuite/jit.dg/test-used-attribute.c
index cb20952c687..446c5c5c31b 100644
--- a/gcc/testsuite/jit.dg/test-used-attribute.c
+++ b/gcc/testsuite/jit.dg/test-used-attribute.c
@@ -107,6 +107,10 @@  int foo() {
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
 /* Check that the "removed" function was inlined, but not the others */
-/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed,\\s+@function" } } */
-/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" } } */
+/* { dg-final { jit-verify-assembler-output-not ".type\\s+removed,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+not_removed,\\s+@function" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".type\\s+foo,\\s+@function" { target { ! *-*-darwin* } } } } */
+
+/* { dg-final { jit-verify-assembler-output-not "\\n_removed:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_not_removed:" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output "\\n_foo:" { target *-*-darwin* } } } */
diff --git a/gcc/testsuite/jit.dg/test-variable-attribute.c b/gcc/testsuite/jit.dg/test-variable-attribute.c
index ea854ff4a9f..219a47d8817 100644
--- a/gcc/testsuite/jit.dg/test-variable-attribute.c
+++ b/gcc/testsuite/jit.dg/test-variable-attribute.c
@@ -40,7 +40,9 @@  int PUBLIC = 12;
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
 /* Check that the attribute was applied correctly */
-/* { dg-final { jit-verify-assembler-output ".hidden\\s+PRIVATE" } } */
-/* { dg-final { jit-verify-assembler-output ".globl\\s+PRIVATE" } } */
-/* { dg-final { jit-verify-assembler-output-not ".hidden\\s+PUBLIC" } } */
-/* { dg-final { jit-verify-assembler-output ".globl\\s+PUBLIC" } } */
+/* { dg-final { jit-verify-assembler-output ".hidden\\s+PRIVATE" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".private_extern\\s+_PRIVATE" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output ".globl\\s+_?PRIVATE" } } */
+/* { dg-final { jit-verify-assembler-output-not ".hidden\\s+PUBLIC" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output-not ".private_extern\\s+_PUBLIC" { target *-*-darwin* } } } */
+/* { dg-final { jit-verify-assembler-output ".globl\\s+_?PUBLIC" } } */
diff --git a/gcc/testsuite/jit.dg/test-weak-attribute.c b/gcc/testsuite/jit.dg/test-weak-attribute.c
index 546ade1c3c4..3ca9485bf41 100644
--- a/gcc/testsuite/jit.dg/test-weak-attribute.c
+++ b/gcc/testsuite/jit.dg/test-weak-attribute.c
@@ -38,4 +38,5 @@  void f () {}
 
 /* { dg-final { jit-verify-output-file-was-created "" } } */
 /* Check that the attribute was applied correctly */
-/* { dg-final { jit-verify-assembler-output ".weak\\s+f" } } */
+/* { dg-final { jit-verify-assembler-output ".weak\\s+f" { target { ! *-*-darwin* } } } } */
+/* { dg-final { jit-verify-assembler-output ".weak_definition\\s+_f" { target *-*-darwin* } } } */