[gcc(refs/users/aoliva/heads/testme)] strub: enable conditional support
Alexandre Oliva
aoliva@gcc.gnu.org
Wed Dec 6 22:47:56 GMT 2023
https://gcc.gnu.org/g:b451e34e642677d1f20c161582c7998c88ccf69d
commit b451e34e642677d1f20c161582c7998c88ccf69d
Author: Alexandre Oliva <oliva@gnu.org>
Date: Wed Dec 6 19:36:02 2023 -0300
strub: enable conditional support
Diff:
---
gcc/config/nvptx/nvptx.cc | 3 +++
gcc/ipa-strub.cc | 27 +++++++++++++++++++++++++++
gcc/target.def | 7 +++++++
3 files changed, 37 insertions(+)
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index ae20802c879..3fb1deb70fd 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -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"
diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 293bec132b8..67b4c94db7d 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -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
@@ -639,9 +640,35 @@ can_strub_p (cgraph_node *node, bool report = false)
{
bool result = true;
+ if (!targetm.have_strub_support_for (node->decl))
+ {
+ result = false;
+
+ if (!report)
+ return result;
+
+ sorry_at (DECL_SOURCE_LOCATION (node->decl),
+ "%qD is not eligible for %<strub%>"
+ " on the target system",
+ node->decl);
+ }
+
if (!report && 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;
diff --git a/gcc/target.def b/gcc/target.def
index 52b83e091b9..11a8a797a05 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -4457,6 +4457,13 @@ 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\
+otherwise return false. The default implementation always returns 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\
More information about the Gcc-cvs
mailing list