diff mbox

Make one extra BB to prevent PHI argument clash (PR, gcov-profile/78582)

Message ID 4afe80c2-3c93-985c-930e-0c237e5f3980@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 29, 2016, 10:46 a.m. UTC
Following ICE has been reduced from bash, where a new CFG does not properly
fill a newly added PHI argument. Problem is solved by adding one extra BB that
precedes the original BB with the PHI. Doing so, we do not add a new PHI argument.

Tests have been running.
Ready to be installed after it finishes?

Thanks,
Martin

Comments

Richard Biener Nov. 29, 2016, 11:34 a.m. UTC | #1
On Tue, Nov 29, 2016 at 11:46 AM, Martin Liška <mliska@suse.cz> wrote:
> Following ICE has been reduced from bash, where a new CFG does not properly

> fill a newly added PHI argument. Problem is solved by adding one extra BB that

> precedes the original BB with the PHI. Doing so, we do not add a new PHI argument.

>

> Tests have been running.

> Ready to be installed after it finishes?


Ok.  (you could avoid the extra forwarder if single_succ (update_bb)
does have no PHIs,
probably not worth the trouble though, or of course add the PHI args
by copying those
from the single_succ_edge)

Richard.

> Thanks,

> Martin
diff mbox

Patch

From f3de44cbf026d3295d42c36e864d469f19fc56cc Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 29 Nov 2016 11:40:04 +0100
Subject: [PATCH] Make one extra BB to prevent PHI argument clash (PR
 gcov-profile/78582)

gcc/testsuite/ChangeLog:

2016-11-29  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78582
	* gcc.dg/pr78582.c: New test.

gcc/ChangeLog:

2016-11-29  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78582
	* tree-profile.c (gimple_gen_time_profiler): Make one extra BB
	to prevent PHI argument clash.
---
 gcc/testsuite/gcc.dg/pr78582.c | 18 ++++++++++++++++++
 gcc/tree-profile.c             |  6 +++---
 2 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr78582.c

diff --git a/gcc/testsuite/gcc.dg/pr78582.c b/gcc/testsuite/gcc.dg/pr78582.c
new file mode 100644
index 0000000..3084e3b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr78582.c
@@ -0,0 +1,18 @@ 
+/* PR target/78582. */
+/* { dg-options "-fprofile-generate" } */
+/* { dg-compile } */
+
+#include <setjmp.h>
+
+void reader_loop () {}
+
+int
+main (int argc, char argv, char env)
+{
+  int a;
+  sigsetjmp (0, 0);
+  argc = a = argc;
+  reader_loop ();
+
+  return 0;
+}
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index a4f9d11..77fb86e 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -461,10 +461,10 @@  void
 gimple_gen_time_profiler (unsigned tag, unsigned base)
 {
   tree type = get_gcov_type ();
-  basic_block cond_bb
-    = split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
-
+  basic_block entry = ENTRY_BLOCK_PTR_FOR_FN (cfun);
+  basic_block cond_bb = split_edge (single_succ_edge (entry));
   basic_block update_bb = split_edge (single_succ_edge (cond_bb));
+  split_edge (single_succ_edge (update_bb));
 
   edge true_edge = single_succ_edge (cond_bb);
   true_edge->flags = EDGE_TRUE_VALUE;
-- 
2.10.2