diff mbox

Fix tree-optimization/78886.

Message ID 3a623200-044e-37da-4a14-d6ee0a286863@suse.cz
State New
Headers show

Commit Message

Martin Liška Dec. 22, 2016, 1:08 p.m. UTC
Patch is pre-approved by Jakub. I guess the same patch can be install to both
release branches after it finishes regression tests, right?

Thanks,
Martin

Comments

Jakub Jelinek Dec. 22, 2016, 1:13 p.m. UTC | #1
On Thu, Dec 22, 2016 at 02:08:35PM +0100, Martin Liška wrote:
> Patch is pre-approved by Jakub. I guess the same patch can be install to both

> release branches after it finishes regression tests, right?


Yes, thanks.

> >From b0efc394e047ebc25386f8cb99f595b8d4c7f83a Mon Sep 17 00:00:00 2001

> From: marxin <mliska@suse.cz>

> Date: Wed, 21 Dec 2016 16:21:45 +0100

> Subject: [PATCH] Fix tree-optimization/78886.

> 

> gcc/testsuite/ChangeLog:

> 

> 2016-12-22  Martin Liska  <mliska@suse.cz>

> 

> 	PR tree-optimization/78886

> 	* gcc.dg/tree-ssa/pr78886.c: New test.

> 

> gcc/ChangeLog:

> 

> 2016-12-22  Martin Liska  <mliska@suse.cz>

> 

> 	PR tree-optimization/78886

> 	* tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS

> 	is equal to NULL.


	Jakub
diff mbox

Patch

From b0efc394e047ebc25386f8cb99f595b8d4c7f83a Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 21 Dec 2016 16:21:45 +0100
Subject: [PATCH] Fix tree-optimization/78886.

gcc/testsuite/ChangeLog:

2016-12-22  Martin Liska  <mliska@suse.cz>

	PR tree-optimization/78886
	* gcc.dg/tree-ssa/pr78886.c: New test.

gcc/ChangeLog:

2016-12-22  Martin Liska  <mliska@suse.cz>

	PR tree-optimization/78886
	* tree-ssa-strlen.c (handle_builtin_malloc): Return when LHS
	is equal to NULL.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr78886.c | 10 ++++++++++
 gcc/tree-ssa-strlen.c                   |  3 +++
 2 files changed, 13 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr78886.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c
new file mode 100644
index 00000000000..97799301547
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr78886.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+void *malloc(unsigned long x);
+
+void foo(void)
+{
+ volatile int i;
+ malloc(1);
+ i;
+}
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 67075f07e29..4a05725ca7c 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -1869,6 +1869,9 @@  handle_builtin_malloc (enum built_in_function bcode, gimple_stmt_iterator *gsi)
 {
   gimple *stmt = gsi_stmt (*gsi);
   tree lhs = gimple_call_lhs (stmt);
+  if (lhs == NULL_TREE)
+    return;
+
   gcc_assert (get_stridx (lhs) == 0);
   int idx = new_stridx (lhs);
   tree length = NULL_TREE;
-- 
2.11.0