diff mbox

[PR70700] Fix ICE in dump_pred_graph

Message ID 5726F960.9020300@mentor.com
State New
Headers show

Commit Message

Tom de Vries May 2, 2016, 6:53 a.m. UTC
Hi,

this patch fixes PR70700, an ICE in 
tree-ssa-structalias.c:dump_pred_graph for the test-case contained in 
the patch.

In the constraint graph, a node representing a variable varinfo_t var is 
represented as the corresponding var->id, ranging from 1 to 
FIRST_REF_NODE - 1.

A node representing a DEREF of a varinfo_t var is represented as the 
corresponding var->id + FIRST_REF_NODE, ranging from FIRST_REF_NODE + 1 
to LAST_REF_NODE.

So, for a DEREF node, we need to substract FIRST_REF_NODE to find the 
corresponding variable. This logic is missing in a print statement in 
dump_pred_graph (which is triggered with TDF_GRAPH), which causes the ICE.

This patch fixes the ICE by substracting FIRST_REF_NODE from the node 
number of a DEREF node to find the varinfo, and prints it as a DEREF 
node (by adding an '*' prefix).

Bootstrapped and reg-tested on x86_64. Extracted graphs from ealias dump 
and verified that valid pdfs were produced.

OK for trunk?

Thanks,
- Tom

Comments

Richard Biener May 2, 2016, 7:05 a.m. UTC | #1
On Mon, 2 May 2016, Tom de Vries wrote:

> Hi,
> 
> this patch fixes PR70700, an ICE in tree-ssa-structalias.c:dump_pred_graph for
> the test-case contained in the patch.
> 
> In the constraint graph, a node representing a variable varinfo_t var is
> represented as the corresponding var->id, ranging from 1 to FIRST_REF_NODE -
> 1.
> 
> A node representing a DEREF of a varinfo_t var is represented as the
> corresponding var->id + FIRST_REF_NODE, ranging from FIRST_REF_NODE + 1 to
> LAST_REF_NODE.
> 
> So, for a DEREF node, we need to substract FIRST_REF_NODE to find the
> corresponding variable. This logic is missing in a print statement in
> dump_pred_graph (which is triggered with TDF_GRAPH), which causes the ICE.
> 
> This patch fixes the ICE by substracting FIRST_REF_NODE from the node number
> of a DEREF node to find the varinfo, and prints it as a DEREF node (by adding
> an '*' prefix).
> 
> Bootstrapped and reg-tested on x86_64. Extracted graphs from ealias dump and
> verified that valid pdfs were produced.
> 
> OK for trunk?

Ok.

Richard.

> Thanks,
> - Tom
>
diff mbox

Patch

Fix ICE in dump_pred_graph

2016-05-02  Marek Polacek  <polacek@redhat.com>
	    Tom de Vries  <tom@codesourcery.com>

	PR tree-optimization/70700
	* tree-ssa-structalias.c (dump_pred_graph): Fix getting varinfo for ids
	bigger than FIRST_REF_NODE.

	* gcc.dg/pr70700.c: New test.

---
 gcc/testsuite/gcc.dg/pr70700.c | 15 +++++++++++++++
 gcc/tree-ssa-structalias.c     |  6 +++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr70700.c b/gcc/testsuite/gcc.dg/pr70700.c
new file mode 100644
index 0000000..613cd29
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr70700.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3 -fdump-tree-ealias-graph" } */
+
+struct S
+{
+  long m;
+};
+
+struct S
+fn1 (struct S *a)
+{
+  if (a->m)
+    a->m |= 2;
+  return *a;
+}
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 0a41494..d66bdfa 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -2241,7 +2241,11 @@  dump_pred_graph (struct scc_info *si, FILE *file)
       if (graph->points_to[i]
 	  && !bitmap_empty_p (graph->points_to[i]))
 	{
-	  fprintf (file, "[label=\"%s = {", get_varinfo (i)->name);
+	  if (i < FIRST_REF_NODE)
+	    fprintf (file, "[label=\"%s = {", get_varinfo (i)->name);
+	  else
+	    fprintf (file, "[label=\"*%s = {",
+		     get_varinfo (i - FIRST_REF_NODE)->name);
 	  unsigned j;
 	  bitmap_iterator bi;
 	  EXECUTE_IF_SET_IN_BITMAP (graph->points_to[i], 0, j, bi)