re PR sanitizer/89124 (__attribute__((no_sanitize_address)) interferes with __attribu...
authorJakub Jelinek <jakub@redhat.com>
Thu, 31 Jan 2019 08:20:45 +0000 (09:20 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 31 Jan 2019 08:20:45 +0000 (09:20 +0100)
PR sanitizer/89124
* ipa-inline.c (sanitize_attrs_match_for_inline_p): Allow inlining
always_inline callees into no_sanitize_address callers.

* c-c++-common/asan/pr89124.c: New test.

From-SVN: r268415

gcc/ChangeLog
gcc/ipa-inline.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/asan/pr89124.c [new file with mode: 0644]

index d1166329e6cab5679335a7c837f42055e8c8e289..a220d57560052d508aba57c686703ac1bade9e90 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/89124
+       * ipa-inline.c (sanitize_attrs_match_for_inline_p): Allow inlining
+       always_inline callees into no_sanitize_address callers.
+
 2019-01-31  Richard Biener  <rguenther@suse.de>
 
        PR rtl-optimization/89115
index 2c1843aa8168b5e4d8e46da97a584d728f0daf71..4ddbfdf772ce034d54dbac37e2a2f5a455879ba7 100644 (file)
@@ -264,6 +264,12 @@ sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee)
   if (!caller || !callee)
     return true;
 
+  /* Allow inlining always_inline functions into no_sanitize_address
+     functions.  */
+  if (!sanitize_flags_p (SANITIZE_ADDRESS, caller)
+      && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee)))
+    return true;
+
   return ((sanitize_flags_p (SANITIZE_ADDRESS, caller)
           == sanitize_flags_p (SANITIZE_ADDRESS, callee))
          && (sanitize_flags_p (SANITIZE_POINTER_COMPARE, caller)
index 917c13e57a2081195cb16633b04b13f25c409aff..48f4bbddd88b0a77abf1c2d69679ddaff7af6214 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/89124
+       * c-c++-common/asan/pr89124.c: New test.
+
 2019-01-30  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/52564
diff --git a/gcc/testsuite/c-c++-common/asan/pr89124.c b/gcc/testsuite/c-c++-common/asan/pr89124.c
new file mode 100644 (file)
index 0000000..c9c870b
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR sanitizer/89124 */
+/* { dg-do compile } */
+
+static int inline __attribute__ ((always_inline))
+foo (int x)
+{
+  return x + 1;
+}
+
+__attribute__ ((no_sanitize_address)) int
+bar (int x)
+{
+  return foo (x);
+}