diff mbox series

[RFC,8/9] asan: memtag: enable pass_asan for memtag sanitizer

Message ID 20241107213937.362703-9-indu.bhagat@oracle.com
State New
Headers show
Series Add -fsanitize=memtag | expand

Commit Message

Indu Bhagat Nov. 7, 2024, 9:39 p.m. UTC
Check for SANITIZER_MEMTAG in the gate function for pass_asan gimple
pass; enable it.

TBD:
  - This commit was initially carved out in order to ensure each patch
    works in isolation.  Need to revisit and double check this.

gcc/ChangeLog:

	* asan.cc (memtag_sanitize_p): Fix definition.
	(gate): Add gate_memtag ().
	(gate_memtag): New definition.
	* asan.h (gate_memtag): New declaration.
---
 gcc/asan.cc | 12 +++++++++---
 gcc/asan.h  |  1 +
 2 files changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/gcc/asan.cc b/gcc/asan.cc
index 92c16c67c7e5..762c83ce5e5f 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -1889,7 +1889,7 @@  hwasan_memintrin (void)
 bool
 memtag_sanitize_p ()
 {
-  return false;
+  return sanitize_flags_p (SANITIZE_MEMTAG);
 }
 
 /* Are we tagging the stack?  */
@@ -4414,7 +4414,7 @@  public:
   opt_pass * clone () final override { return new pass_asan (m_ctxt); }
   bool gate (function *) final override
   {
-    return gate_asan () || gate_hwasan ();
+    return gate_asan () || gate_hwasan () || gate_memtag ();
   }
   unsigned int execute (function *) final override
   {
@@ -4456,7 +4456,7 @@  public:
   /* opt_pass methods: */
   bool gate (function *) final override
     {
-      return !optimize && (gate_asan () || gate_hwasan ());
+      return !optimize && (gate_asan () || gate_hwasan () || gate_memtag ());
     }
   unsigned int execute (function *) final override
   {
@@ -4990,4 +4990,10 @@  gate_hwasan ()
   return hwasan_sanitize_p ();
 }
 
+bool
+gate_memtag ()
+{
+  return memtag_sanitize_p ();
+}
+
 #include "gt-asan.h"
diff --git a/gcc/asan.h b/gcc/asan.h
index d169a769f780..8aa16c9931ed 100644
--- a/gcc/asan.h
+++ b/gcc/asan.h
@@ -57,6 +57,7 @@  extern bool gate_hwasan (void);
 extern bool memtag_sanitize_p (void);
 extern bool memtag_sanitize_stack_p (void);
 extern bool memtag_sanitize_allocas_p (void);
+extern bool gate_memtag (void);
 
 bool hwassist_sanitize_p (void);
 bool hwassist_sanitize_stack_p (void);