diff mbox series

testsuite: Use -fno-ipa-icf in gcc.dg/stack-check-2.c

Message ID 9a8c3137-db22-9217-2307-6dffe964a67a@redhat.com
State New
Headers show
Series testsuite: Use -fno-ipa-icf in gcc.dg/stack-check-2.c | expand

Commit Message

Joseph Myers Oct. 24, 2024, 6:42 p.m. UTC
One test failing with a -std=gnu23 default that I wanted to
investigate further is gcc.dg/stack-check-2.c.  The failures are

FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not optimized "tail call"
FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not tailc "tail call"

but it turns out the tail calls in question are not the ones that test
is actually checking for.  Rather, when () is interpreted as (void) in
C23 mode, ICF notices that certain functions are identical and so
turns test_indirect_2 into a tail call to text_indirect_1 and
test_indirect_casted_2 into a tail call to test_indirect_casted_1
(which it didn't do previously when one function used () and one used
(void)).

To avoid these spurious failures, make the test use -fno-ipa-icf
rather than relying on () and (void) giving different function types
to avoid ICF.

Tested for x86_64-pc-linux-gnu.  OK to commit?

	* gcc.dg/stack-check-2.c: Use -fno-ipa-icf.

Comments

Jakub Jelinek Oct. 24, 2024, 6:44 p.m. UTC | #1
On Thu, Oct 24, 2024 at 06:42:01PM +0000, Joseph Myers wrote:
> One test failing with a -std=gnu23 default that I wanted to
> investigate further is gcc.dg/stack-check-2.c.  The failures are
> 
> FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not optimized "tail call"
> FAIL: gcc.dg/stack-check-2.c scan-tree-dump-not tailc "tail call"
> 
> but it turns out the tail calls in question are not the ones that test
> is actually checking for.  Rather, when () is interpreted as (void) in
> C23 mode, ICF notices that certain functions are identical and so
> turns test_indirect_2 into a tail call to text_indirect_1 and
> test_indirect_casted_2 into a tail call to test_indirect_casted_1
> (which it didn't do previously when one function used () and one used
> (void)).
> 
> To avoid these spurious failures, make the test use -fno-ipa-icf
> rather than relying on () and (void) giving different function types
> to avoid ICF.
> 
> Tested for x86_64-pc-linux-gnu.  OK to commit?
> 
> 	* gcc.dg/stack-check-2.c: Use -fno-ipa-icf.

LGTM.

	Jakub
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/stack-check-2.c b/gcc/testsuite/gcc.dg/stack-check-2.c
index 196c4bbfbdd..a821c0ef865 100644
--- a/gcc/testsuite/gcc.dg/stack-check-2.c
+++ b/gcc/testsuite/gcc.dg/stack-check-2.c
@@ -12,7 +12,7 @@ 
    depend on to elide stack probes.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fstack-clash-protection -fdump-tree-tailc -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fstack-clash-protection -fdump-tree-tailc -fdump-tree-optimized -fno-ipa-icf" } */
 /* { dg-require-effective-target supports_stack_clash_protection } */
 
 extern void foo (void) __attribute__ ((__noreturn__));