Added changelog entries.

-- >8 --

If a check-function-bodies test is compiled using -fstack-protector*,
-fhardened, -fstack-check*, or -fstack-clash-protection, but the test is
not asking explicitly for those via dg-options or
dg-additional-options, then mark the test as unsupported.  Since these
features influence prologue/epilogue it is rarely useful to check the
full function body, if the test is not explicitly prepared for those.
This might happen when the testsuite is passed additional options as
e.g. via --target_board='unix{-fstack-protector-all}'.

gcc/ChangeLog:

        * doc/sourcebuild.texi: Document new behavior.

gcc/testsuite/ChangeLog:

        * lib/scanasm.exp: Skip check-function-bodies in case of
        implicit prologue/epilogue changes.

Co-Authored-By: Jakub Jelinek <ja...@redhat.com>
---
 gcc/doc/sourcebuild.texi      |  9 +++++++++
 gcc/testsuite/lib/scanasm.exp | 17 +++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index a9193040b37..274b5f73a40 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3630,6 +3630,15 @@ command line.  This can help if a source file is 
compiled both with
 and without optimization, since it is rarely useful to check the full
 function body for unoptimized code.
 
+Similarly, if a check-function-bodies test is compiled using
+@samp{-fstack-protector*}, @samp{-fhardened}, @samp{-fstack-check*}, or
+@samp{-fstack-clash-protection}, but the test is not asking explicitly for
+those via @samp{dg-options} or @samp{dg-additional-options}, then mark the
+test as unsupported.  Since these features influence prologue/epilogue it is
+rarely useful to check the full function body, if the test is not explicitly
+prepared for those.  This might happen when the testsuite is passed additional
+options as e.g.@: via @samp{--target_board='unix@{-fstack-protector-all@}'}.
+
 The first line of the expected output for a function @var{fn} has the form:
 
 @smallexample
diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp
index a2311de5704..0cfd8672185 100644
--- a/gcc/testsuite/lib/scanasm.exp
+++ b/gcc/testsuite/lib/scanasm.exp
@@ -1042,6 +1042,23 @@ proc check-function-bodies { args } {
     # The name might include a list of options; extract the file name.
     set filename [lindex $testcase 0]
 
+    # The set of options passed to gcc
+    global compiler_flags
+    # The set of options specified in the individual test case
+    # including dg-options and dg-additional-options
+    set current_compiler_flags [current_compiler_flags]
+    if { ( [lsearch -glob $compiler_flags "-fstack-protector*"] >= 0
+          && [lsearch -regex $current_compiler_flags 
"-f(no-)?stack-protector"] == -1 )
+        || ( [lsearch -exact $compiler_flags "-fhardened"] >= 0
+             && [lsearch -regex $current_compiler_flags "-f(no-)?hardened"] == 
-1 )
+        || ( [lsearch -glob $compiler_flags "-fstack-check*"] >= 0
+             && [lsearch -regex $current_compiler_flags 
"-f(no-)?stack-check.*"] == -1 )
+        || ( [lsearch -exact $compiler_flags "-fstack-clash-protection"] >= 0
+             && [lsearch -regex $current_compiler_flags 
"-f(no-)?stack-clash-protection"] == -1 ) } {
+       unsupported "$testcase: skip check-function-bodies due to implicit 
prologue/epilogue changes e.g. by stack protector"
+       return
+    }
+
     global srcdir
     set input_filename "$srcdir/$filename"
     set output_filename "[file rootname [file tail $filename]]"
-- 
2.49.0

Reply via email to