]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
strub: enable conditional support
authorAlexandre Oliva <oliva@adacore.com>
Thu, 7 Dec 2023 15:58:20 +0000 (12:58 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 7 Dec 2023 15:58:20 +0000 (12:58 -0300)
Targets that don't expose callee stacks to callers, such as nvptx, as
well as -fsplit-stack compilations, violate fundamental assumptions of
the current strub implementation.  This patch enables targets to
disable strub, and disables it when -fsplit-stack is enabled.

When strub support is disabled, the testsuite will now skip strub
tests, and libgcc will not build the strub runtime components.

for  gcc/ChangeLog

* target.def (have_strub_support_for): New hook.
* doc/tm.texi.in: Document it.
* doc/tm.texi: Rebuild.
* ipa-strub.cc: Include target.h.
(strub_target_support_p): New.
(can_strub_p): Call it.  Test for no flag_split_stack.
(pass_ipa_strub::adjust_at_calls_call): Check for target
support.
* config/nvptx/nvptx.cc (TARGET_HAVE_STRUB_SUPPORT_FOR):
Disable.
* doc/sourcebuild.texi (strub): Document new effective
target.

for  gcc/testsuite/ChangeLog

* c-c++-common/strub-split-stack.c: New.
* c-c++-common/strub-unsupported.c: New.
* c-c++-common/strub-unsupported-2.c: New.
* c-c++-common/strub-unsupported-3.c: New.
* lib/target-supports.exp (check_effective_target_strub): New.
* c-c++-common/strub-O0.c: Require effective target strub.
* c-c++-common/strub-O1.c: Likewise.
* c-c++-common/strub-O2.c: Likewise.
* c-c++-common/strub-O2fni.c: Likewise.
* c-c++-common/strub-O3.c: Likewise.
* c-c++-common/strub-O3fni.c: Likewise.
* c-c++-common/strub-Og.c: Likewise.
* c-c++-common/strub-Os.c: Likewise.
* c-c++-common/strub-all1.c: Likewise.
* c-c++-common/strub-all2.c: Likewise.
* c-c++-common/strub-apply1.c: Likewise.
* c-c++-common/strub-apply2.c: Likewise.
* c-c++-common/strub-apply3.c: Likewise.
* c-c++-common/strub-apply4.c: Likewise.
* c-c++-common/strub-at-calls1.c: Likewise.
* c-c++-common/strub-at-calls2.c: Likewise.
* c-c++-common/strub-defer-O1.c: Likewise.
* c-c++-common/strub-defer-O2.c: Likewise.
* c-c++-common/strub-defer-O3.c: Likewise.
* c-c++-common/strub-defer-Os.c: Likewise.
* c-c++-common/strub-internal1.c: Likewise.
* c-c++-common/strub-internal2.c: Likewise.
* c-c++-common/strub-parms1.c: Likewise.
* c-c++-common/strub-parms2.c: Likewise.
* c-c++-common/strub-parms3.c: Likewise.
* c-c++-common/strub-relaxed1.c: Likewise.
* c-c++-common/strub-relaxed2.c: Likewise.
* c-c++-common/strub-short-O0-exc.c: Likewise.
* c-c++-common/strub-short-O0.c: Likewise.
* c-c++-common/strub-short-O1.c: Likewise.
* c-c++-common/strub-short-O2.c: Likewise.
* c-c++-common/strub-short-O3.c: Likewise.
* c-c++-common/strub-short-Os.c: Likewise.
* c-c++-common/strub-strict1.c: Likewise.
* c-c++-common/strub-strict2.c: Likewise.
* c-c++-common/strub-tail-O1.c: Likewise.
* c-c++-common/strub-tail-O2.c: Likewise.
* c-c++-common/strub-var1.c: Likewise.
* c-c++-common/torture/strub-callable1.c: Likewise.
* c-c++-common/torture/strub-callable2.c: Likewise.
* c-c++-common/torture/strub-const1.c: Likewise.
* c-c++-common/torture/strub-const2.c: Likewise.
* c-c++-common/torture/strub-const3.c: Likewise.
* c-c++-common/torture/strub-const4.c: Likewise.
* c-c++-common/torture/strub-data1.c: Likewise.
* c-c++-common/torture/strub-data2.c: Likewise.
* c-c++-common/torture/strub-data3.c: Likewise.
* c-c++-common/torture/strub-data4.c: Likewise.
* c-c++-common/torture/strub-data5.c: Likewise.
* c-c++-common/torture/strub-indcall1.c: Likewise.
* c-c++-common/torture/strub-indcall2.c: Likewise.
* c-c++-common/torture/strub-indcall3.c: Likewise.
* c-c++-common/torture/strub-inlinable1.c: Likewise.
* c-c++-common/torture/strub-inlinable2.c: Likewise.
* c-c++-common/torture/strub-ptrfn1.c: Likewise.
* c-c++-common/torture/strub-ptrfn2.c: Likewise.
* c-c++-common/torture/strub-ptrfn3.c: Likewise.
* c-c++-common/torture/strub-ptrfn4.c: Likewise.
* c-c++-common/torture/strub-pure1.c: Likewise.
* c-c++-common/torture/strub-pure2.c: Likewise.
* c-c++-common/torture/strub-pure3.c: Likewise.
* c-c++-common/torture/strub-pure4.c: Likewise.
* c-c++-common/torture/strub-run1.c: Likewise.
* c-c++-common/torture/strub-run2.c: Likewise.
* c-c++-common/torture/strub-run3.c: Likewise.
* c-c++-common/torture/strub-run4.c: Likewise.
* c-c++-common/torture/strub-run4c.c: Likewise.
* c-c++-common/torture/strub-run4d.c: Likewise.
* c-c++-common/torture/strub-run4i.c: Likewise.
* g++.dg/strub-run1.C: Likewise.
* g++.dg/torture/strub-init1.C: Likewise.
* g++.dg/torture/strub-init2.C: Likewise.
* g++.dg/torture/strub-init3.C: Likewise.
* gnat.dg/strub_attr.adb: Likewise.
* gnat.dg/strub_ind.adb: Likewise.
* gnat.dg/strub_access.adb: Likewise.
* gnat.dg/strub_access1.adb: Likewise.
* gnat.dg/strub_disp.adb: Likewise.
* gnat.dg/strub_disp1.adb: Likewise.
* gnat.dg/strub_ind1.adb: Likewise.
* gnat.dg/strub_ind2.adb: Likewise.
* gnat.dg/strub_intf.adb: Likewise.
* gnat.dg/strub_intf1.adb: Likewise.
* gnat.dg/strub_intf2.adb: Likewise.
* gnat.dg/strub_renm.adb: Likewise.
* gnat.dg/strub_renm1.adb: Likewise.
* gnat.dg/strub_renm2.adb: Likewise.
* gnat.dg/strub_var.adb: Likewise.
* gnat.dg/strub_var1.adb: Likewise.

for  libgcc/ChangeLog

* configure.ac: Check for strub support.
* configure: Rebuilt.
* Makefile.in: Compile strub.c conditionally.

103 files changed:
gcc/config/nvptx/nvptx.cc
gcc/doc/sourcebuild.texi
gcc/doc/tm.texi
gcc/doc/tm.texi.in
gcc/ipa-strub.cc
gcc/target.def
gcc/testsuite/c-c++-common/strub-O0.c
gcc/testsuite/c-c++-common/strub-O1.c
gcc/testsuite/c-c++-common/strub-O2.c
gcc/testsuite/c-c++-common/strub-O2fni.c
gcc/testsuite/c-c++-common/strub-O3.c
gcc/testsuite/c-c++-common/strub-O3fni.c
gcc/testsuite/c-c++-common/strub-Og.c
gcc/testsuite/c-c++-common/strub-Os.c
gcc/testsuite/c-c++-common/strub-all1.c
gcc/testsuite/c-c++-common/strub-all2.c
gcc/testsuite/c-c++-common/strub-apply1.c
gcc/testsuite/c-c++-common/strub-apply2.c
gcc/testsuite/c-c++-common/strub-apply3.c
gcc/testsuite/c-c++-common/strub-apply4.c
gcc/testsuite/c-c++-common/strub-at-calls1.c
gcc/testsuite/c-c++-common/strub-at-calls2.c
gcc/testsuite/c-c++-common/strub-defer-O1.c
gcc/testsuite/c-c++-common/strub-defer-O2.c
gcc/testsuite/c-c++-common/strub-defer-O3.c
gcc/testsuite/c-c++-common/strub-defer-Os.c
gcc/testsuite/c-c++-common/strub-internal1.c
gcc/testsuite/c-c++-common/strub-internal2.c
gcc/testsuite/c-c++-common/strub-parms1.c
gcc/testsuite/c-c++-common/strub-parms2.c
gcc/testsuite/c-c++-common/strub-parms3.c
gcc/testsuite/c-c++-common/strub-relaxed1.c
gcc/testsuite/c-c++-common/strub-relaxed2.c
gcc/testsuite/c-c++-common/strub-short-O0-exc.c
gcc/testsuite/c-c++-common/strub-short-O0.c
gcc/testsuite/c-c++-common/strub-short-O1.c
gcc/testsuite/c-c++-common/strub-short-O2.c
gcc/testsuite/c-c++-common/strub-short-O3.c
gcc/testsuite/c-c++-common/strub-short-Os.c
gcc/testsuite/c-c++-common/strub-split-stack.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/strub-strict1.c
gcc/testsuite/c-c++-common/strub-strict2.c
gcc/testsuite/c-c++-common/strub-tail-O1.c
gcc/testsuite/c-c++-common/strub-tail-O2.c
gcc/testsuite/c-c++-common/strub-unsupported-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/strub-unsupported-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/strub-unsupported.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/strub-var1.c
gcc/testsuite/c-c++-common/torture/strub-callable1.c
gcc/testsuite/c-c++-common/torture/strub-callable2.c
gcc/testsuite/c-c++-common/torture/strub-const1.c
gcc/testsuite/c-c++-common/torture/strub-const2.c
gcc/testsuite/c-c++-common/torture/strub-const3.c
gcc/testsuite/c-c++-common/torture/strub-const4.c
gcc/testsuite/c-c++-common/torture/strub-data1.c
gcc/testsuite/c-c++-common/torture/strub-data2.c
gcc/testsuite/c-c++-common/torture/strub-data3.c
gcc/testsuite/c-c++-common/torture/strub-data4.c
gcc/testsuite/c-c++-common/torture/strub-data5.c
gcc/testsuite/c-c++-common/torture/strub-indcall1.c
gcc/testsuite/c-c++-common/torture/strub-indcall2.c
gcc/testsuite/c-c++-common/torture/strub-indcall3.c
gcc/testsuite/c-c++-common/torture/strub-inlinable1.c
gcc/testsuite/c-c++-common/torture/strub-inlinable2.c
gcc/testsuite/c-c++-common/torture/strub-ptrfn1.c
gcc/testsuite/c-c++-common/torture/strub-ptrfn2.c
gcc/testsuite/c-c++-common/torture/strub-ptrfn3.c
gcc/testsuite/c-c++-common/torture/strub-ptrfn4.c
gcc/testsuite/c-c++-common/torture/strub-pure1.c
gcc/testsuite/c-c++-common/torture/strub-pure2.c
gcc/testsuite/c-c++-common/torture/strub-pure3.c
gcc/testsuite/c-c++-common/torture/strub-pure4.c
gcc/testsuite/c-c++-common/torture/strub-run1.c
gcc/testsuite/c-c++-common/torture/strub-run2.c
gcc/testsuite/c-c++-common/torture/strub-run3.c
gcc/testsuite/c-c++-common/torture/strub-run4.c
gcc/testsuite/c-c++-common/torture/strub-run4c.c
gcc/testsuite/c-c++-common/torture/strub-run4d.c
gcc/testsuite/c-c++-common/torture/strub-run4i.c
gcc/testsuite/g++.dg/strub-run1.C
gcc/testsuite/g++.dg/torture/strub-init1.C
gcc/testsuite/g++.dg/torture/strub-init2.C
gcc/testsuite/g++.dg/torture/strub-init3.C
gcc/testsuite/gnat.dg/strub_access.adb
gcc/testsuite/gnat.dg/strub_access1.adb
gcc/testsuite/gnat.dg/strub_attr.adb
gcc/testsuite/gnat.dg/strub_disp.adb
gcc/testsuite/gnat.dg/strub_disp1.adb
gcc/testsuite/gnat.dg/strub_ind.adb
gcc/testsuite/gnat.dg/strub_ind1.adb
gcc/testsuite/gnat.dg/strub_ind2.adb
gcc/testsuite/gnat.dg/strub_intf.adb
gcc/testsuite/gnat.dg/strub_intf1.adb
gcc/testsuite/gnat.dg/strub_intf2.adb
gcc/testsuite/gnat.dg/strub_renm.adb
gcc/testsuite/gnat.dg/strub_renm1.adb
gcc/testsuite/gnat.dg/strub_renm2.adb
gcc/testsuite/gnat.dg/strub_var.adb
gcc/testsuite/gnat.dg/strub_var1.adb
gcc/testsuite/lib/target-supports.exp
libgcc/Makefile.in
libgcc/configure
libgcc/configure.ac

index ae20802c87996e1a38030dc9e6939a2900f91ab8..3fb1deb70fda1768a206c95f0088c71a9f289392 100644 (file)
@@ -7789,6 +7789,9 @@ nvptx_asm_output_def_from_decls (FILE *stream, tree name, tree value)
 #undef TARGET_LIBC_HAS_FUNCTION
 #define TARGET_LIBC_HAS_FUNCTION nvptx_libc_has_function
 
+#undef TARGET_HAVE_STRUB_SUPPORT_FOR
+#define TARGET_HAVE_STRUB_SUPPORT_FOR hook_bool_tree_false
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-nvptx.h"
index c9909026854174df0c9bfa1841687922e554f7cc..26a7e9c35070383611c8dfbc884197ff713e4f62 100644 (file)
@@ -2983,6 +2983,9 @@ Target supports statically linking @samp{libgfortran}.
 @item string_merging
 Target supports merging string constants at link time.
 
+@item strub
+Target supports attribute @code{strub} for stack scrubbing.
+
 @item ucn
 Target supports compiling and assembling UCN.
 
index 89a1735dd7992fee9001f8a8c36d88344c529021..768ada0af52227a62f666ead3d303887041a9544 100644 (file)
@@ -3450,6 +3450,12 @@ in DWARF 2 debug information.  The default is zero.  A different value
 may reduce the size of debug information on some ports.
 @end defmac
 
+@deftypefn {Target Hook} bool TARGET_HAVE_STRUB_SUPPORT_FOR (tree)
+Returns true if the target supports stack scrubbing for the given function
+or type, otherwise return false.  The default implementation always returns
+true.
+@end deftypefn
+
 @defmac TARGET_STRUB_USE_DYNAMIC_ARRAY
 If defined to nonzero, @code{__strub_leave} will allocate a dynamic
 array covering the stack range that needs scrubbing before clearing it.
index ebc1d3de5caaa3771097a4b9b5d712d770ba738f..4fe0805394ea4d45dfa6ffb41eb052fd32649a0d 100644 (file)
@@ -2686,6 +2686,8 @@ in DWARF 2 debug information.  The default is zero.  A different value
 may reduce the size of debug information on some ports.
 @end defmac
 
+@hook TARGET_HAVE_STRUB_SUPPORT_FOR
+
 @defmac TARGET_STRUB_USE_DYNAMIC_ARRAY
 If defined to nonzero, @code{__strub_leave} will allocate a dynamic
 array covering the stack range that needs scrubbing before clearing it.
index 293bec132b885139c2bb94c13fefdaacc797d126..2afb7a455751d3f6e956ed50741ae89651896f1d 100644 (file)
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ipa-strub.h"
 #include "symtab-thunks.h"
 #include "attr-fnspec.h"
+#include "target.h"
 
 /* This file introduces two passes that, together, implement
    machine-independent stack scrubbing, strub for short.  It arranges
@@ -631,17 +632,60 @@ strub_always_inline_p (cgraph_node *node)
   return lookup_attribute ("always_inline", DECL_ATTRIBUTES (node->decl));
 }
 
+/* Return TRUE iff the target has strub support for T, a function
+   decl, or a type used in an indirect call, and optionally REPORT the
+   reasons for ineligibility.  If T is a type and error REPORTing is
+   enabled, the LOCation (of the indirect call) should be provided.  */
+static inline bool
+strub_target_support_p (tree t, bool report = false,
+                       location_t loc = UNKNOWN_LOCATION)
+{
+  bool result = true;
+
+  if (!targetm.have_strub_support_for (t))
+    {
+      result = false;
+
+      if (!report)
+       return result;
+
+      if (DECL_P (t))
+       sorry_at (DECL_SOURCE_LOCATION (t),
+                 "%qD is not eligible for %<strub%>"
+                 " on the target system", t);
+      else
+       sorry_at (loc,
+                 "unsupported %<strub%> call"
+                 " on the target system");
+    }
+
+  return result;
+}
+
 /* Return TRUE iff NODE is potentially eligible for any strub-enabled mode, and
    optionally REPORT the reasons for ineligibility.  */
 
 static inline bool
 can_strub_p (cgraph_node *node, bool report = false)
 {
-  bool result = true;
+  bool result = strub_target_support_p (node->decl, report);
 
-  if (!report && strub_always_inline_p (node))
+  if (!report && (!result || strub_always_inline_p (node)))
     return result;
 
+  if (flag_split_stack)
+    {
+      result = false;
+
+      if (!report)
+       return result;
+
+      sorry_at (DECL_SOURCE_LOCATION (node->decl),
+               "%qD is not eligible for %<strub%>"
+               " because %<-fsplit-stack%> is enabled",
+               node->decl);
+    }
+
   if (lookup_attribute ("noipa", DECL_ATTRIBUTES (node->decl)))
     {
       result = false;
@@ -2417,6 +2461,12 @@ pass_ipa_strub::adjust_at_calls_call (cgraph_edge *e, int named_args,
                         && (TREE_TYPE (gimple_call_arg (ocall, named_args))
                             == get_pwmt ())));
 
+  tree tsup;
+  if (!(tsup = gimple_call_fndecl (ocall)))
+    tsup = TREE_TYPE (TREE_TYPE (gimple_call_fn (ocall)));
+  if (!strub_target_support_p (tsup, true, gimple_location (ocall)))
+    return;
+
   /* If we're already within a strub context, pass on the incoming watermark
      pointer, and omit the enter and leave calls around the modified call, as an
      optimization, or as a means to satisfy a tail-call requirement.  */
index 52b83e091b94bdda8d1584a262a82d8f0f402d58..08218f3a42adff15150fa815391a9096832665c4 100644 (file)
@@ -4457,6 +4457,14 @@ otherwise return false.  The default implementation always returns true.",
  bool, (void),
  hook_bool_void_true)
 
+DEFHOOK
+(have_strub_support_for,
+ "Returns true if the target supports stack scrubbing for the given function\n\
+or type, otherwise return false.  The default implementation always returns\n\
+true.",
+ bool, (tree),
+ hook_bool_tree_true)
+
 DEFHOOK
 (have_speculation_safe_value,
 "This hook is used to determine the level of target support for\n\
index c7a79a6ea0d8a00e1a193f02dbfe3a033be48f74..f0a3f7b4c6f9ae7402102a036a6ca9d3537d4e81 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O0 -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 /* At -O0, none of the strub builtins are expanded inline.  */
 
index 96285c975d98e285005b46bb7f0c43b1a1fab4e7..50403426b18f2472d98d5d84bb46ec3028ada125 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O1 -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 /* At -O1, without -fno-inline, we fully expand enter, but neither update nor
    leave.  */
index 8edc0d8aa13219605659a035749fcbdc75d1cbea..37e02998e318e377d9d4f53072ccc937fc36106e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 /* At -O2, without -fno-inline, we fully expand enter and update, and add a test
    around the leave call.  */
index c6d900cf3c45b6c2b7614a41868ac1319eef6d77..905e2c6b2ffcad471213555e5d4782b14b3cf208 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fstrub=strict -fdump-rtl-expand -fno-inline" } */
+/* { dg-require-effective-target strub } */
 
 /* With -fno-inline, none of the strub builtins are inlined.  */
 
index 33ee465e51cb6bbfcf877bcecfda25aca9f39689..3bbf132bdf1ea5a1c36798391c15b31bdf8fc826 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O3 -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 int __attribute__ ((__strub__)) var;
 
index 2936f82079e188ab776a8e1c76b4abb4fcca5999..c46fce38e5c91efbe426a965e114872caca72e5b 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O3 -fstrub=strict -fdump-rtl-expand -fno-inline" } */
+/* { dg-require-effective-target strub } */
 
 /* With -fno-inline, none of the strub builtins are inlined.  */
 
index 479746e57d87e7f40620ae6cd82efe84fa4e64eb..3b8eb19765cd66281b71b3d71ea89c89fd113d1f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Og -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 /* At -Og, without -fno-inline, we fully expand enter, but neither update nor
    leave.  */
index 2241d4ea07f27fa8cbffe9812a1c50d1b8d90864..8cfb253d6764c3853c6ca096d822605083f3812e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Os -fstrub=strict -fdump-rtl-expand" } */
+/* { dg-require-effective-target strub } */
 
 /* At -Os, without -fno-inline, we fully expand enter, and also update.  The
    expanded update might be larger than a call proper, but argument saving and
index a322bcc5da606764dd90bed4716266386dd91f9d..2037f681f2973a3186f17f3f80a744e0ae05e05a 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=all -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* h becomes STRUB_CALLABLE, rather than STRUB_INLINABLE, because of the
    strub-enabling -fstrub flag, and gets inlined before pass_ipa_strub.  */
index db60026d0e080032c5049e98ffcde4b6c8244482..c026e7d9d289b251261d5fb8458d7b5ef14ec34e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=all -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* g becomes STRUB_INTERNAL, because of the flag.  Without inline, force_output
    is set for static non-inline functions when not optimizing, and that keeps
index 2f462adc1efe0ba1ae96118504d2764701442b87..3edc89c54eea14d58b0cfed61e703fc27bc50bcb 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 void __attribute__ ((__strub__ ("callable")))
 apply_function (void *args)
index a5d7551f5da5cbe6aa63c374d78d68ae1de802ac..838fc752734500d550d36ef3fba192e24d247531 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 extern void __attribute__ ((__strub__))
 apply_function (void *args);
index 64422a0d1e8801b42ea630b1b7de4e245a54e227..0206e4d930e7da27902e93a1c5b7bf2b24bfd072 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 void __attribute__ ((__strub__))
 apply_function (void *args)
index 15ffaa031b8992e3e8b0f7817e21db35e9f4ee67..e82504728b2c6b0c2071055262383580bda85200 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fstrub=strict -fdump-ipa-strubm" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that implicit enabling of strub mode selects internal strub when the
    function uses __builtin_apply_args, that prevents the optimization to
index b70843b4215a40a359928ab3661e1c085888b354..a20acc0a48a58ef25a271461964ca2a52d67da25 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=at-calls -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* h becomes STRUB_CALLABLE, rather than STRUB_INLINABLE, because of the
    strub-enabling -fstrub flag, and gets inlined before pass_ipa_strub.  */
index 97a3988a6b9224abfe54d904b00fe3806d03d854..7915b33a39a0a93fc7b79c979576e15c42b9540f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=at-calls -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* g does NOT become STRUB_AT_CALLS because it's not viable.  Without inline,
    force_output is set for static non-inline functions when not optimizing, and
index 3d73431b3dcd38e241d74955441e9dad9b65e277..3689998b5a3231fd5216657441be5e33a598ccca 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict -O1" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a strub function called by another strub function does NOT defer
    the strubbing to its caller at -O1.  */
index fddf3c745e7e64afedf9911e5dc86ad41ccdff0a..9e01949db6be9cd2ca42dff0af5dbafd49c9a14a 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict -O2" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a strub function called by another strub function does NOT defer
    the strubbing to its caller at -O2.  */
index 7ebc65b58dd721a2e1f77b8977488b51299898e2..40ee8edd1e0e68b886ae15c042bfb5e4682d3099 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict -O3" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a strub function called by another strub function defers the
    strubbing to its caller at -O3.  */
index fbaf85fe0fafe97bb76645c887070faf1024c89a..67ea9f0463975067550ba33117c18cc1b8026376 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict -Os" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a strub function called by another strub function defers the
    strubbing to its caller at -Os.  */
index e9d7b7b9ee0a83181d036070e2d8f10b88917575..d17254904e50ab2af85d94c5b495f155e16dd7b2 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=internal -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* h becomes STRUB_CALLABLE, rather than STRUB_INLINABLE, because of the
    strub-enabling -fstrub flag, and gets inlined before pass_ipa_strub.  */
index 8b8e15a51c71ceddedf2b1641dc25484e1fc5437..afc9189701f8265d850a88ce4bf7bfae51438a51 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=internal -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* g becomes STRUB_INTERNAL, because of the flag.  */
 static void
index 0a4a7539d34896870d60c02274b848d06adf9cb7..f410b268971a6b1821ca43269705a63fdd1a08f5 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 #include <stdarg.h>
 
index 147171d96d5a1d4df4e69389e2be7fb95afac5bb..6f572115a88c38d6a05a2397cb4c885f34baad46 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 #include <stdarg.h>
 
index 4e92682895a4314dde15d367cd814f55163b87e8..7383fea9ce8818b035f438df97547709f316e376 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that uses of a strub variable implicitly enables internal strub for
    publicly-visible functions, and causes the same transformations to their
index e2f9d8aebca58d81786b228446c7c8517c36e08d..d2b4b52c51e60cf58e342618130c244e2344e4ee 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The difference between relaxed and strict in this case is that we accept the
    call from one internal-strub function to another.  Without the error,
index 98474435d2e591d3f6a5ad30c20b3e970ab9482a..9e5a8e76b6c3d1be9aed5d60459f4a739ba78c6d 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed -fdump-ipa-strubm -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The difference between relaxed and strict in this case is that we accept the
    call from one internal-strub function to another.  */
index 1de15342595e410e4bd2403b163e9894104a0fcd..aaeba2a2159a92ad8535685b646a517ea580293b 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O0 -fstrub=strict -fexceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  */
 
index f9209c819004bb9bf33a899eb979867f02219928..30cbdd819f1765224636a6d2c4a43a94cfc611fd 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O0 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  */
 
index bed1dcfb54a45ab2869adec23a6e181a0a6eca4b..911fdfb6db9a555b1fa6d8c6940012c87c5fa67e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O1 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  */
 
index 6bf0071f52b933ce1858fd1409dcb95485cfce86..9b23ee3ac33127afa55b32b0d1105e0ddd2f1d9a 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  */
 
index 4732f515bf70c0ea322ffcded64fa5130870a6cb..4b3a8f843ea194573a707b2ede66c79ce36b0934 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O3 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  At -O3 and -Os, we omit
    enter and leave calls within strub contexts, passing on the enclosing
index 8d6424c479a3a48729ca1cff3a1e43fbc0c2489e..3627a2406000ba5fec3a328e4004280b964b2cfd 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-Os -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.  At -O3 and -Os, we omit
    enter and leave calls within strub contexts, passing on the enclosing
diff --git a/gcc/testsuite/c-c++-common/strub-split-stack.c b/gcc/testsuite/c-c++-common/strub-split-stack.c
new file mode 100644 (file)
index 0000000..7a030cd
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-fsplit-stack" } */
+/* { dg-require-effective-target strub } */
+/* { dg-require-effective-target split_stack } */
+
+void __attribute__ ((__strub__))
+f () {} /* { dg-message "not eligible|requested" } */
+
+void __attribute__ ((__strub__ ("internal")))
+g () {} /* { dg-message "not eligible|requested" } */
index 368522442066e10fdfea3da6f13be4a0a5899aa9..503eb1734e36fa621907d14e48228aa869711e1f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strubm" } */
+/* { dg-require-effective-target strub } */
 
 static int __attribute__ ((__strub__)) var;
 
index b4f2888321821379da31d5b7859a02068aad791e..3bf1aa30b4af1081b365208132b1ad82c201389f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strubm" } */
+/* { dg-require-effective-target strub } */
 
 static int __attribute__ ((__strub__)) var;
 
index e48e0610e079b09e41ac6fe5d739944c442586cb..ba4b1623e281a57b76a1bb4a1a0d3196c15f05c6 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O1 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 #include "strub-tail-O2.c"
 
index 87cda7ab21b16237b191aa398d54358c9c3406d5..043813b1de467c02197bca001f208256287267c6 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fstrub=strict -fno-exceptions -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that the expected strub calls are issued.
    Tail calls are short-circuited at -O2+.  */
diff --git a/gcc/testsuite/c-c++-common/strub-unsupported-2.c b/gcc/testsuite/c-c++-common/strub-unsupported-2.c
new file mode 100644 (file)
index 0000000..3586f4f
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+/* Check that, when strub is not supported (so no dg-required-effective-target
+   strub above), we report when pointers to strub functions are called.  This
+   cannot be part of strub-unsupported.c because errors in the strub-mode pass
+   prevent the main strub pass, where errors at calls are detected, from
+   running.  */
+
+void __attribute__ ((__strub__ ("at-calls"))) (*p) (void);
+
+void m () {
+  p (); /* { dg-message "unsupported" "" { target { ! strub } } } */
+}
diff --git a/gcc/testsuite/c-c++-common/strub-unsupported-3.c b/gcc/testsuite/c-c++-common/strub-unsupported-3.c
new file mode 100644 (file)
index 0000000..d6fb4c5
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+
+/* Check that, when strub is not supported (so no dg-required-effective-target
+   strub above), we report when strub functions that are not defined are
+   called.  This cannot be part of strub-unsupported-2.c because errors in the
+   strub-mode pass prevent the main strub pass, where errors at calls are
+   detected, from running.  */
+
+extern void __attribute__ ((__strub__))
+s (void); /* { dg-message "not eligible|requested" "" { target { ! strub } } } */
+
+extern void __attribute__ ((__strub__ ("internal")))
+t (void); /* { dg-message "not eligible|requested" "" { target { ! strub } } } */
+
+void m () {
+  s ();
+  t ();
+}
diff --git a/gcc/testsuite/c-c++-common/strub-unsupported.c b/gcc/testsuite/c-c++-common/strub-unsupported.c
new file mode 100644 (file)
index 0000000..cb5c404
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+/* Check that, when strub is not supported (so no dg-required-effective-target
+   strub above), we report when strub functions are defined, and when they're
+   called in ways that would require changes.  */
+
+void __attribute__ ((__strub__))
+f (void) {} /* { dg-message "not eligible|requested" "" { target { ! strub } } } */
+
+void __attribute__ ((__strub__ ("internal")))
+g (void) {} /* { dg-message "not eligible|requested" "" { target { ! strub } } } */
+
+/* This only gets an error when called, see strub-unsupported-2.c.  */
+void __attribute__ ((__strub__ ("at-calls"))) (*p) (void);
+
+/* These too, see strub-unsupported-3.c.  */
+extern void __attribute__ ((__strub__))
+s (void);
+
+extern void __attribute__ ((__strub__ ("internal")))
+t (void);
index eb6250fd39c90c428cf2bc4f578865dfe286eef7..67014aa5de84a733a153a02f191986e5aa890d02 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target strub } */
 
 int __attribute__ ((strub)) x;
 float __attribute__ ((strub)) f;
index b5e45ab0525adc7feb9f171a71434c6ed5f83746..86dbee6746d1b93b10329daa8f395eb519d10dd8 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that strub and non-strub functions can be called from non-strub
    contexts, and that strub and callable functions can be called from strub
index 96aa7fe4b07f70511f03f3595e104b3850621d86..9da120f61564598ab94622201fed45182d45e79d 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that impermissible (cross-strub-context) calls are reported.  */
 
index 5e956cb1a9b6b0361e7b1cd757832a4501ad7074..22056713cce4bdb7f8eb3507bbcb96a547039878 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub const function call, we issue an asm
    statement to make sure the watermark passed to it is held in memory before
index 73d650292dfbf6df690d643dd98e71bbde639ee6..a105c66d7a9c9b1d9925c042e9c9784f83068bdd 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub implicitly-const function call, we issue an
    asm statement to make sure the watermark passed to it is held in memory
index 2584f1f974a588273e9bf7a443331dfc64922614..386200c2784a4c3c5c5be29eb6f3093534e18325 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub const wrapping call, we issue an asm statement
    to make sure the watermark passed to it is held in memory before the call,
index d819f54ec02308d6965082076ecb8c2a6e061d28..817e9fa2118b67fdf082d769e368853fba912d9e 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub implicitly-const wrapping call, we issue an
    asm statement to make sure the watermark passed to it is held in memory
index 7c27a2a1a6dca4603717558bf630f84eecf6db8d..132ab63ef733a4635d9f5ce9e467e4900567206b 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The pointed-to data enables strubbing if accessed.  */
 int __attribute__ ((__strub__)) var;
index e66d903780afd295cb1f4f845e17de87d956e46d..b660702d26e7543d87443b44bdf38324f6d5a6e0 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The pointer itself is a strub variable, enabling internal strubbing when
    its value is used.  */
index 5e08e0e58c658670e58abf58bb87c64eadc21156..fc44eef6f8fb5a7e45d56893f2756bb8efd52585 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The pointer itself is a strub variable, that would enable internal strubbing
    if its value was used.  Here, it's only overwritten, so no strub.  */
index a818e7a38bb5ffe9a0645acb038dcca64057e8a7..85e2f59055b574e4025f01f628c742b0287011b1 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* The pointer itself is a strub variable, that would enable internal strubbing
    if its value was used.  Here, it's only overwritten, so no strub.  */
index ddb0b5c0543b09c8093edf2340d3bbe520c77bfe..0a5edac414df1a63d6e58c4fee5babf8fa41f950 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 /* It would be desirable to issue at least warnings for these.  */
 
index c165f312f16dec59fc48ef478e8da6beb029c993..988954e7ed6bc3d0ee5e9e9509585763d5f42625 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 typedef void __attribute__ ((__strub__)) fntype ();
 fntype (*ptr);
index 69fcff8d3763dcbfb50c3ffd3b76f8adf314ecf4..d3ca91389a700fae344cf9949d2ef21e9a68da76 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 typedef void __attribute__ ((__strub__)) fntype (int, int);
 fntype (*ptr);
index ff006224909bd5de9d73cb6fec8ee55cbab6ba03..89b5979cf7b7872fa435a4473533f1043e1d2d9d 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 typedef void __attribute__ ((__strub__)) fntype (int, int, ...);
 fntype (*ptr);
index 614b02228ba29c77730d45477183bf10dc376820..4917dda8826d980497ed2e821059347a53097f95 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed" } */
+/* { dg-require-effective-target strub } */
 
 inline void __attribute__ ((strub ("internal"), always_inline))
 inl_int_ali (void)
index f9a6b4a16faf813aba08e82a9ffb4ae4b129786d..c45903856d4ff032fac8b56238d07a1adda3638a 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=all" } */
+/* { dg-require-effective-target strub } */
 
 #include "strub-inlinable1.c"
 
index b4a7f3992bbaa3a7b8bbfc287a431d77027a2b58..b0d6139f0a870f2656d10aa3bea0de05c28daa07 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 typedef void ft (void);
 typedef void ft2 (int, int);
index ef634d351265fddf2843a6c69e4c51cebf3ec702..1148c246f20599a1e75ad23a3879452f3d0642ef 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed -Wpedantic" } */
+/* { dg-require-effective-target strub } */
 
 /* C++ does not warn about the partial incompatibilities.
 
index e1f179e160e5c9187f87f580070a3b9d9fa397d7..06a72d86d2c58b6eab68474abe4070ef304d76c5 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed -Wpedantic -fpermissive" } */
 /* { dg-prune-output "command-line option .-fpermissive." } */
+/* { dg-require-effective-target strub } */
 
 /* See strub-ptrfn2.c.  */
 
index 70b558afad040e461384d7aae89fc7943d302886..83ea1af7056e7043463d89fc147f7b6ea3f420ab 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=relaxed" } */
+/* { dg-require-effective-target strub } */
 
 /* This is strub-ptrfn2.c without -Wpedantic.
 
index a262a086837b26b4650a4dbf6cb05f461d05a6ce..2643136f178ccf649e5977cb8f41171a26b7776a 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub pure function call, we issue an asm statement
    to make sure the watermark passed to it is not assumed to be unchanged.  */
index 4c4bd50c209a0a4ca6ae105221386b409e820b71..8bda129b77dc6e09030a2b54821eeb29f4b3000f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub implicitly-pure function call, we issue an asm
    statement to make sure the watermark passed to it is not assumed to be
index ce195c6b1f1b673cb59305dd7b5cb9e704e51a93..00bcbdd097af892b5d17776607fdab5eac797ec1 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub pure wrapping call, we issue an asm statement
    to make sure the watermark passed to it is not assumed to be unchanged.  */
index 75cd54ccb5b5d83658c3d487d951e0bea14626db..ea7c40e7912b4a59d5a6f056120e20d84e8e3b99 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that, along with a strub implicitly-pure wrapping call, we issue an asm
    statement to make sure the watermark passed to it is not assumed to be
index 7458b3fb54da5dea223dcc50da3681f7ed027b1c..fdf100428631d2e13723e6d0f178a16426549da9 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a non-strub function leaves a string behind in the stack, and that
    equivalent strub functions don't.  Avoid the use of red zones by avoiding
index 5d60a7775f4bb94d825abc62c8d967f3c9cf3848..1228a665997218570988e52403aa9cffc7b2353f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict" } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a non-strub function leaves a string behind in the stack, and that
    equivalent strub functions don't.  Allow red zones to be used.  */
index c2ad710858e876afb1d54ff02702ffc13ba65a9c..e5047a988f5bf1b835125795f613d15c6f0726e1 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict" } */
 /* { dg-require-effective-target alloca } */
+/* { dg-require-effective-target strub } */
 
 /* Check that a non-strub function leaves a string behind in the stack, and that
    equivalent strub functions don't.  */
index 3b36b8e5d68ef64345b7aa37a70e4b5ea3186f3a..0e84a4bab80fcf2b0a4abcff22ad9ab9465b99e1 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=all" } */
 /* { dg-require-effective-target alloca } */
+/* { dg-require-effective-target strub } */
 
 /* Check that multi-level, multi-inlined functions still get cleaned up as
    expected, without overwriting temporary stack allocations while they should
index 57f9baf758ded17b709742cd61f8c1d2ee25411d..edc98486dc93aa92586198593bd08edb3c203bb8 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=at-calls" } */
 /* { dg-require-effective-target alloca } */
+/* { dg-require-effective-target strub } */
 
 #include "strub-run4.c"
index 08de3f1c3b17cedda4adbc204378874fce95d924..487ed08bb6606af4f0e4785fe574e18b83cb0ae9 100644 (file)
@@ -1,6 +1,7 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=strict" } */
 /* { dg-require-effective-target alloca } */
+/* { dg-require-effective-target strub } */
 
 #define ATTR_STRUB_AT_CALLS __attribute__ ((__strub__ ("at-calls")))
 
index 459f6886c54990845fb569aaa00567a2b7400898..a85447ffabfaedf0ffb2f3d72aa486087b63e47f 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-options "-fstrub=internal" } */
 /* { dg-require-effective-target alloca } */
+/* { dg-require-effective-target strub } */
 
 #include "strub-run4.c"
index 0d367fb83d09d1e72ce488df226920b7b3f21e32..beb8b811f8fca7bd0b20544ac452f0269fe4c8cf 100644 (file)
@@ -1,5 +1,6 @@
 // { dg-do run }
 // { dg-options "-fstrub=internal" }
+// { dg-require-effective-target strub }
 
 // Check that we don't get extra copies.
 
index c226ab10ff651a35e90dc2eed602426d8d346999..6ae45fadd70ba6950009aa41252183fe4824e844 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+// { dg-require-effective-target strub }
 
 extern int __attribute__((__strub__)) initializer ();
 
index a7911f1fa7212ac11ba4ea851f6211f245e25e1e..8f4849c7fde78d2cfbde2f12091c7e45a11e2a97 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+// { dg-require-effective-target strub }
 
 extern int __attribute__((__strub__)) initializer ();
 
index 6ebebcd01e8ea0d37c2b810e6ac51697ef453c14..14f28e3c276bd2163169d6d5f771170c5a313365 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-fstrub=strict -fdump-ipa-strub" } */
+// { dg-require-effective-target strub }
 
 extern int __attribute__((__strub__)) initializer ();
 
index 29e6996ecf61c1fba86305ffae8dbe8c66d49a32..488a2d64afe3197567a44f7cd8eef270f1c89e04 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=relaxed -fdump-ipa-strubm" }
+--  { dg-require-effective-target strub }
 
 --  The main subprogram doesn't read from the automatic variable, but
 --  being an automatic variable, its presence should be enough for the
index dae47060164369ab8149c584bc6834be262cb4ac..4a8653c4d843f6c8704463a8295c68a97f0a96d4 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=relaxed" }
+--  { dg-require-effective-target strub }
 
 --  Check that we reject 'Access of a strub variable whose type does
 --  not carry a strub modifier.
index 10445d7cf8451d029158342e15fd57f2d871c758..eb7826dc990f419a2094036be10aa5b6c04da6af 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict -fdump-ipa-strubm -fdump-ipa-strub" }
+--  { dg-require-effective-target strub }
 
 package body Strub_Attr is
    E : exception;
index 3dbcc4a357cba07a54903dc4c45d9d190f659137..f23d4675def381497267aa2ab9d93058789bffc9 100644 (file)
@@ -1,4 +1,5 @@
 --  { dg-do compile }
+--  { dg-require-effective-target strub }
 
 procedure Strub_Disp is
    package Foo is
index 09756a74b7d81be6a5c0d09ca741972dc24e4199..9c4c7f696371d9286a908d737009ea9f44122cda 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fdump-ipa-strub" }
+--  { dg-require-effective-target strub }
 
 -- Check that at-calls dispatching calls are transformed.
 
index da56acaa957d232230ac3b5926bbe9f8951784f5..613db69305e0544c18b2f9a04ff9b2ea1a472dbf 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict" }
+--  { dg-require-effective-target strub }
 
 --  This is essentially the same test as strub_attr.adb, 
 --  but applying attributes to access types as well.
index 825e395e6819c3ae134328465ce0e0a4b75d4ca6..245b0a830f6915aad125f04aca772a0b9573bf5f 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict -fdump-ipa-strubm" }
+--  { dg-require-effective-target strub }
 
 --  This is essentially the same test as strub_attr.adb, 
 --  but with an explicit conversion.
index e918b392631178843a011d59100d3f30a3b466bc..b9bfe50e9296e5b0516556423a486b761060f983 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict" }
+--  { dg-require-effective-target strub }
 
 --  This is essentially the same test as strub_attr.adb, 
 --  but with an explicit conversion.
index 8f0212a75866f852f0ac3e4fff7249688e506a0c..f43854705d073f75772ba811d9f693ae7a5a1f35 100644 (file)
@@ -1,4 +1,5 @@
 --  { dg-do compile }
+--  { dg-require-effective-target strub }
 
 --  Check that strub mode mismatches between overrider and overridden
 --  subprograms are reported.
index bf77321cef7908fdad02bff278cff701b03c274b..7a38a4c49ba8d2bf85dba883c086efcf93cd4a21 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fdump-ipa-strub" }
+--  { dg-require-effective-target strub }
 
 -- Check that at-calls dispatching calls to interfaces are transformed.
 
index e8880dbc437308a01b1d6d27ef2f986faf2f5b74..7992b7344fb878ebba8132ed9aafcf885b43079b 100644 (file)
@@ -1,4 +1,5 @@
 --  { dg-do compile }
+--  { dg-require-effective-target strub }
 
 --  Check that strub mode mismatches between overrider and overridden
 --  subprograms are reported even when the overriders for an
index 217367e712d82d7b387c16bdde0dcac45f8e2faa..abfb120b51468e3c022d6d08ec21206d31d02970 100644 (file)
@@ -1,4 +1,5 @@
 --  { dg-do compile }
+--  { dg-require-effective-target strub }
 
 procedure Strub_Renm is
    procedure P (X : Integer);
index a11adbfb5a9d66a8fa4e4b415bb8bc31b218952c..68d3230b5356c0cde2423dbb783f19b65bf36b10 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=relaxed -fdump-ipa-strub" }
+--  { dg-require-effective-target strub }
 
 procedure Strub_Renm1 is
    V : Integer := 0;
index c488c20826fdbfacceea10636876bb7f45f2465d..3cb81ea03f763e5307eea54eb951f90b75a27b71 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict -fdump-ipa-strub" }
+--  { dg-require-effective-target strub }
 
 procedure Strub_Renm2 is
    V : Integer := 0;
index 3d158de28031f1d06f955cab420a83e4bb79a2d3..7c6affa06d4abab21ff5b814029f25912ba41838 100644 (file)
@@ -1,5 +1,6 @@
 --  { dg-do compile }
 --  { dg-options "-fstrub=strict -fdump-ipa-strubm" }
+--  { dg-require-effective-target strub }
 
 -- We don't read from the automatic variable, but being an automatic
 --  variable, its presence should be enough for the procedure to get
index 6a504e09198b687207f6845237f04ba7b6362bbd..64b7e65fe9b0f41ccf802cd3ac5503b32a093485 100644 (file)
@@ -1,4 +1,5 @@
 --  { dg-do compile }
+--  { dg-require-effective-target strub }
 
 with Strub_Attr;
 procedure Strub_Var1 is
index 3fcce6be49d6fbfeb723f7db849352e6e55a4f64..40a60c198cfe82cc217bee0556c78227c6631c6d 100644 (file)
@@ -1302,6 +1302,13 @@ proc check_stack_check_available { stack_kind } {
     } "$stack_opt"]
 }
 
+# Return 1 if the target supports stack scrubbing.
+proc check_effective_target_strub {} {
+    return [check_no_compiler_messages strub assembly {
+       void __attribute__ ((__strub__)) fn (void) {}
+    } ""]
+}
+
 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
 # for trivial code, 0 otherwise.  As some targets (ARM for example) only
 # warn when -fprofile-use is also supplied we test that combination too.
index d8163c5af9903b40aaf06efe3bcbd447165ea334..3f77283490ef695bf21d28719bbef2a72242fc9f 100644 (file)
@@ -434,7 +434,7 @@ LIB2ADD += enable-execute-stack.c
 LIB2ADD += $(srcdir)/hardcfr.c
 
 # Stack scrubbing infrastructure.
-LIB2ADD += $(srcdir)/strub.c
+@HAVE_STRUB_SUPPORT@LIB2ADD += $(srcdir)/strub.c
 
 # While emutls.c has nothing to do with EH, it is in LIB2ADDEH*
 # instead of LIB2ADD because that's the way to be sure on some targets
index cf149209652e34e63b42bf9bd5ff2cd4e3ff99be..567158955a329f63cad54a88d42be16026a956ba 100755 (executable)
@@ -593,6 +593,7 @@ asm_hidden_op
 extra_parts
 cpu_type
 get_gcc_base_ver
+HAVE_STRUB_SUPPORT
 thread_header
 tm_defines
 tm_file
@@ -5702,6 +5703,31 @@ esac
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strub support" >&5
+$as_echo_n "checking for strub support... " >&6; }
+if ${libgcc_cv_strub_support+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+void __attribute__ ((__strub__)) fn (void) {}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libgcc_cv_strub_support=yes
+else
+  libgcc_cv_strub_support=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_strub_support" >&5
+$as_echo "$libgcc_cv_strub_support" >&6; }
+if test "x$libgcc_cv_strub_support" != xno; then
+  HAVE_STRUB_SUPPORT=
+else
+  HAVE_STRUB_SUPPORT='# '
+fi
+
+
 # Determine what GCC version number to use in filesystem paths.
 
   get_gcc_base_ver="cat"
index 2fc9d5d7c93e91842d96e5195d29c53c6a015c49..9c0e415501a80f6872795218954f773055386438 100644 (file)
@@ -694,6 +694,19 @@ AC_SUBST(tm_defines)
 # Map from thread model to thread header.
 GCC_AC_THREAD_HEADER([$target_thread_file])
 
+AC_CACHE_CHECK([for strub support],
+  [libgcc_cv_strub_support],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE([void __attribute__ ((__strub__)) fn (void) {}])],
+    [libgcc_cv_strub_support=yes],
+    [libgcc_cv_strub_support=no])])
+if test "x$libgcc_cv_strub_support" != xno; then
+  HAVE_STRUB_SUPPORT=
+else
+  HAVE_STRUB_SUPPORT='# '
+fi
+AC_SUBST(HAVE_STRUB_SUPPORT)
+
 # Determine what GCC version number to use in filesystem paths.
 GCC_BASE_VER