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: Re: GCC 9 backports
Date: Thu, 04 Jul 2019 09:23:00 -0000	[thread overview]
Message-ID: <c117d891-5b5c-54fd-5c58-f036477333d2@suse.cz> (raw)
In-Reply-To: <de4746dd-889f-5fe1-263d-ea760d1cad8d@suse.cz>

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

Hi.

There are 2 more patches that I've just tested.

Martin

[-- Attachment #2: 0002-Backport-r272993.patch --]
[-- Type: text/x-patch, Size: 2181 bytes --]

From ae7d66dad2e43e18cf2889803e30e57bc00f88ad Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Jul 2019 08:32:25 +0000
Subject: [PATCH 2/2] Backport r272993

gcc/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	PR tree-optimization/90892
	* builtins.c (inline_expand_builtin_string_cmp): Handle '\0'
	in string constants.

gcc/testsuite/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	PR tree-optimization/90892
	* gcc.dg/pr90892.c: New test.
---
 gcc/builtins.c                 | 17 ++++++++++++++---
 gcc/testsuite/gcc.dg/pr90892.c | 14 ++++++++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr90892.c

diff --git a/gcc/builtins.c b/gcc/builtins.c
index d37d73fc4a0..9bcb310c015 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7124,8 +7124,19 @@ inline_expand_builtin_string_cmp (tree exp, rtx target)
     return NULL_RTX;
 
   /* For strncmp, if the length is not a const, not qualify.  */
-  if (is_ncmp && !tree_fits_uhwi_p (len3_tree))
-    return NULL_RTX;
+  if (is_ncmp)
+    {
+      if (!tree_fits_uhwi_p (len3_tree))
+	return NULL_RTX;
+      else
+	len3 = tree_to_uhwi (len3_tree);
+    }
+
+  if (src_str1 != NULL)
+    len1 = strnlen (src_str1, len1) + 1;
+
+  if (src_str2 != NULL)
+    len2 = strnlen (src_str2, len2) + 1;
 
   int const_str_n = 0;
   if (!len1)
@@ -7140,7 +7151,7 @@ inline_expand_builtin_string_cmp (tree exp, rtx target)
   gcc_checking_assert (const_str_n > 0);
   length = (const_str_n == 1) ? len1 : len2;
 
-  if (is_ncmp && (len3 = tree_to_uhwi (len3_tree)) < length)
+  if (is_ncmp && len3 < length)
     length = len3;
 
   /* If the length of the comparision is larger than the threshold,
diff --git a/gcc/testsuite/gcc.dg/pr90892.c b/gcc/testsuite/gcc.dg/pr90892.c
new file mode 100644
index 00000000000..e4b5310807a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr90892.c
@@ -0,0 +1,14 @@
+/* PR tree-optimization/90892 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+const char *a = "A\0b";
+
+int
+main()
+{
+  if (__builtin_strncmp(a, "A\0", 2) != 0)
+    __builtin_abort ();
+
+  return 0;
+}
-- 
2.22.0


[-- Attachment #3: 0001-Backport-r272992.patch --]
[-- Type: text/x-patch, Size: 1693 bytes --]

From 7a9894e91edfff690db6d9e5935585952a025327 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 3 Jul 2019 08:31:35 +0000
Subject: [PATCH 1/2] Backport r272992

gcc/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	PR middle-end/90899
	* multiple_target.c (create_dispatcher_calls): Add to comdat
	group only if set for ifunc.

gcc/testsuite/ChangeLog:

2019-07-03  Martin Liska  <mliska@suse.cz>

	PR middle-end/90899
	* gcc.target/i386/pr90899.c: New test.
---
 gcc/multiple_target.c                   | 3 ++-
 gcc/testsuite/gcc.target/i386/pr90899.c | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr90899.c

diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 0a87241b251..e93c60e7adb 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -158,7 +158,8 @@ create_dispatcher_calls (struct cgraph_node *node)
 	    {
 	      symtab_node *source = ref->referring;
 	      source->create_reference (inode, IPA_REF_ALIAS);
-	      source->add_to_same_comdat_group (inode);
+	      if (inode->get_comdat_group ())
+		source->add_to_same_comdat_group (inode);
 	    }
 	  else
 	    gcc_unreachable ();
diff --git a/gcc/testsuite/gcc.target/i386/pr90899.c b/gcc/testsuite/gcc.target/i386/pr90899.c
new file mode 100644
index 00000000000..e0e2d5ac6bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr90899.c
@@ -0,0 +1,6 @@
+/* PR middle-end/90899 */
+/* { dg-do compile } */
+/* { dg-require-ifunc "" } */
+
+__attribute__ ((target_clones ("default", "arch=slm"))) static int f () { return 0; }
+__attribute__ ((alias ("f"))) __typeof (f) g;
-- 
2.22.0


  reply	other threads:[~2019-07-04  9:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14  8:45 Martin Liška
2019-05-14  8:47 ` Martin Liška
2019-05-24  7:43   ` Martin Liška
2019-07-04  9:23     ` Martin Liška [this message]
2019-07-22  9:36       ` Martin Liška
2019-08-23 11:56         ` Martin Liška
2019-09-02  8:56           ` Martin Liška
2019-10-23 12:12             ` Martin Liška
2020-02-28 17:51               ` Martin Liška
2020-03-10 10:09                 ` Martin Liška
2020-04-03 10:32                   ` Martin Liška
2020-04-20  9:25                     ` Martin Liška
2020-10-02 10:05                       ` Martin Liška
2020-10-02 11:15                         ` Martin Liška
2020-10-15  9:07                           ` Martin Liška
2020-10-16  8:51                           ` Martin Liška

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=c117d891-5b5c-54fd-5c58-f036477333d2@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).