public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: GCC 8 backports
Date: Wed, 23 May 2018 08:43:00 -0000	[thread overview]
Message-ID: <ba2054eb-5b7a-3c87-d498-5f462438fff7@suse.cz> (raw)

[-- Attachment #1: Type: text/plain, Size: 130 bytes --]

Hi.

I'm going to backport following 2 revisions.
Patches can bootstrap on x86_64-linux-gnu and survive regression tests.

Martin

[-- Attachment #2: 0001-patch-260154.patch --]
[-- Type: text/x-patch, Size: 3945 bytes --]

From 3308817aa11be9d43cd564d249dae1c28bf41015 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 11 May 2018 07:37:35 +0000
Subject: Backport r260154

gcc/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* doc/extend.texi: Document LLVM style format for no_sanitize
	attribute.

gcc/c-family/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* c-attribs.c (handle_no_sanitize_attribute): Iterate all
	TREE_LIST values.

gcc/testsuite/ChangeLog:

2018-05-11  Martin Liska  <mliska@suse.cz>

        PR sanitizer/85556
	* c-c++-common/ubsan/attrib-6.c: New test.

---
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index 9bddc1aad4f..d302b4f22c7 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -403,7 +403,7 @@ const struct attribute_spec c_common_attribute_table[] =
 			      0, 0, true, false, false, false,
 			      handle_no_address_safety_analysis_attribute,
 			      NULL },
-  { "no_sanitize",	      1, 1, true, false, false, false,
+  { "no_sanitize",	      1, -1, true, false, false, false,
 			      handle_no_sanitize_attribute, NULL },
   { "no_sanitize_address",    0, 0, true, false, false, false,
 			      handle_no_sanitize_address_attribute, NULL },
@@ -683,22 +683,26 @@ static tree
 handle_no_sanitize_attribute (tree *node, tree name, tree args, int,
 			      bool *no_add_attrs)
 {
+  unsigned int flags = 0;
   *no_add_attrs = true;
-  tree id = TREE_VALUE (args);
   if (TREE_CODE (*node) != FUNCTION_DECL)
     {
       warning (OPT_Wattributes, "%qE attribute ignored", name);
       return NULL_TREE;
     }

-  if (TREE_CODE (id) != STRING_CST)
+  for (; args; args = TREE_CHAIN (args))
     {
-      error ("no_sanitize argument not a string");
-      return NULL_TREE;
-    }
+      tree id = TREE_VALUE (args);
+      if (TREE_CODE (id) != STRING_CST)
+	{
+	  error ("no_sanitize argument not a string");
+	  return NULL_TREE;
+	}

-  char *string = ASTRDUP (TREE_STRING_POINTER (id));
-  unsigned int flags = parse_no_sanitize_attribute (string);
+      char *string = ASTRDUP (TREE_STRING_POINTER (id));
+      flags |= parse_no_sanitize_attribute (string);
+    }

   add_no_sanitize_value (*node, flags);

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 9d085844cfd..a4664cad819 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2977,6 +2977,8 @@ mentioned in @var{sanitize_option}.  A list of values acceptable by
 @smallexample
 void __attribute__ ((no_sanitize ("alignment", "object-size")))
 f () @{ /* @r{Do something.} */; @}
+void __attribute__ ((no_sanitize ("alignment,object-size")))
+g () @{ /* @r{Do something.} */; @}
 @end smallexample

 @item no_sanitize_address
diff --git a/gcc/testsuite/c-c++-common/ubsan/attrib-6.c b/gcc/testsuite/c-c++-common/ubsan/attrib-6.c
new file mode 100644
index 00000000000..2af70c8c2cf
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/attrib-6.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=undefined" } */
+
+static void __attribute__((no_sanitize("foobar")))
+foo (void) { /* { dg-warning "attribute directive ignored" } */
+}
+
+static void __attribute__((no_sanitize("address,undefined")))
+foo2 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "undefined")))
+foo3 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address", "")))
+foo4 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address", "address,address")))
+foo5 (void) {
+}
+
+static void __attribute__((no_sanitize("address", "address,kernel-address,thread,leak,undefined,vptr,shift,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,bounds-strict,alignment,object-size,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum")))
+foo6 (void) {
+}
--
2.16.3

[-- Attachment #3: 0002-patch-260566.patch --]
[-- Type: text/x-patch, Size: 2411 bytes --]

From 8203f7efd03cc82717ab0416a151e96d3a7b8f4b Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 23 May 2018 07:40:43 +0000
Subject: Backport r260566

gcc/ChangeLog:

2018-05-23  Yury Gribov  <tetra2005@gmail.com>

	PR tree-optimization/85822
	* tree-vrp.c (is_masked_range_test): Fix handling of negative
	constants.

gcc/testsuite/ChangeLog:

2018-05-23  Yury Gribov  <tetra2005@gmail.com>

	PR tree-optimization/85822
	* c-c++-common/pr85822.c: New test.

---
diff --git a/gcc/testsuite/c-c++-common/pr85822.c b/gcc/testsuite/c-c++-common/pr85822.c
new file mode 100644
index 00000000000..3b09188ab47
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr85822.c
@@ -0,0 +1,27 @@
+/* { dg-options "-O2" } */
+/* { dg-do run } */
+
+static const long long int TagTypeNumber = 0xffff000000000000ll;
+
+long long int x;
+
+void foo(void)
+{
+  x = TagTypeNumber + 1;
+}
+
+int main(int argc, char **argv)
+{
+  if (argc > 0)
+    foo ();
+
+  if ((x & TagTypeNumber) == TagTypeNumber)
+  {
+    unsigned y = (unsigned)x;
+    __builtin_printf ("v: %u\n", y);
+    if (y != 1)
+      __builtin_abort ();
+  }
+
+  return 0;
+}
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index aa53db65576..6c482dd3e46 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3844,10 +3844,10 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
    Such comparison can yield assertions like
      X >= XX...X00...0
      X <= XX...X11...1
-   in case of COND_OP being NE_EXPR or
+   in case of COND_OP being EQ_EXPR or
      X < XX...X00...0
      X > XX...X11...1
-   in case of EQ_EXPR.  */
+   in case of NE_EXPR.  */

 static bool
 is_masked_range_test (tree name, tree valt, enum tree_code cond_code,
@@ -3867,6 +3867,10 @@ is_masked_range_test (tree name, tree valt, enum tree_code cond_code,

   wi::tree_to_wide_ref mask = wi::to_wide (maskt);
   wide_int inv_mask = ~mask;
+  /* Must have been removed by now so don't bother optimizing.  */
+  if (mask == 0 || inv_mask == 0)
+    return false;
+
   /* Assume VALT is INTEGER_CST.  */
   wi::tree_to_wide_ref val = wi::to_wide (valt);

@@ -3907,9 +3911,6 @@ is_masked_range_test (tree name, tree valt, enum tree_code cond_code,
   *low = wide_int_to_tree (type, val);
   *high = wide_int_to_tree (type, val | inv_mask);

-  if (wi::neg_p (val, TYPE_SIGN (type)))
-    std::swap (*low, *high);
-
   return true;
 }

--
2.16.3

             reply	other threads:[~2018-05-23  8:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23  8:43 Martin Liška [this message]
2018-08-16 10:14 ` Martin Liška
2018-09-18  9:37   ` Martin Liška
2018-09-25  6:52     ` Martin Liška
2018-10-03 10:09       ` Martin Liška
2018-11-20 10:58         ` Martin Liška
2018-12-27 14:59           ` Martin Liška
2018-12-28 11:46             ` Sudakshina Das
2019-01-02 11:46               ` Martin Liška
2019-01-02 11:50                 ` Jan Hubicka
2019-01-03  8:46                   ` Martin Liška
2019-02-14 11:23           ` Martin Liška
2019-02-14 13:57             ` Martin Liška
2019-03-11  9:39               ` Martin Liška
2019-03-15  8:39                 ` Martin Liška
2019-03-28  8:53                   ` Martin Liška
2019-05-24  7:42                     ` Martin Liška
2019-07-04 10:17                       ` Martin Liška
2020-01-15 10:15 ` Martin Liška
2020-03-02  9:33 ` Martin Liška
2020-03-29 17:17 ` Martin Liška
2020-04-03 10:32   ` Martin Liška
2019-05-06 14:00 Martin Liška
2019-05-14  9:11 ` Martin Liška
2019-07-22  9:36   ` Martin Liška
2019-05-07 16:17 Marek Polacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ba2054eb-5b7a-3c87-d498-5f462438fff7@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).