From: Stefan Schulze Frielinghaus <[email protected]>
During the removal of -m31, the else branch for TARGET_64BIT in function
s390_function_profiler() was rewritten incorrectly, i.e., previously we
had
if (flag_fentry)
{ ... }
else if (TARGET_64BIT)
{
if (flag_nop_mcount) ...
else { ... }
} else { ... }
and with r17-2272
if (flag_fentry)
{ ... }
if (flag_nop_mcount) ...
else { ... }
Therefore, the function emits for -mfentry one call to __fentry__ and
then falls through into the sequence which is meant for -mno-fentry.
Fixed by making the -mnop-mcount/default handling an else branch of
the flag_fentry case.
gcc/ChangeLog:
* config/s390/s390.cc (s390_function_profiler): Make the
-mnop-mcount/default handling an else branch of the
flag_fentry case.
gcc/testsuite/ChangeLog:
* gcc.target/s390/mfentry-m64.c: Test for exactly one call.
---
gcc/config/s390/s390.cc | 3 +--
gcc/testsuite/gcc.target/s390/mfentry-m64.c | 9 +++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index ba576680229..61ca55161f9 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -14109,8 +14109,7 @@ s390_function_profiler (FILE *file, int labelno
ATTRIBUTE_UNUSED)
else
output_asm_insn ("brasl\t0,%2%K2", op);
}
-
- if (flag_nop_mcount)
+ else if (flag_nop_mcount)
output_asm_nops ("-mnop-mcount", /* stg */ 3 + /* brasl */ 3 +
/* lg */ 3);
else
diff --git a/gcc/testsuite/gcc.target/s390/mfentry-m64.c
b/gcc/testsuite/gcc.target/s390/mfentry-m64.c
index aa3fc81248f..d5020050469 100644
--- a/gcc/testsuite/gcc.target/s390/mfentry-m64.c
+++ b/gcc/testsuite/gcc.target/s390/mfentry-m64.c
@@ -6,3 +6,12 @@ profileme (void)
{
/* { dg-final { scan-assembler "brasl\t0,__fentry__" } } */
}
+
+/* During the removal of -m31, the else branch for TARGET_64BIT in function
+ s390_function_profiler() was rewritten incorrectly, causing to emit two
+ __fentry__ calls. Verify that with -mfentry exactly one call to __fentry__
+ is emitted and that -mno-nop-mcount doesn't lead to a sequence which saves
+ %r14 and a call. */
+/* { dg-final { scan-assembler-times "__fentry__" 1 } } */
+/* { dg-final { scan-assembler-times "brasl\t" 1 } } */
+/* { dg-final { scan-assembler-not "stg\t%r14,8\\(%r15\\)" } } */
--
2.55.0