[patch/committed] PR middle-end/65233 make walk-ssa_copies handle empty PHIs

Aldy Hernandez aldyh@redhat.com
Mon Mar 2 05:34:00 GMT 2015


As I mention in the PR...

What's happening here is that the ipa_polymorphic_call_context 
constructor is calling walk_ssa_copies on a PHI node that has no 
arguments.  This happens because finalize_jump_threads eventually 
removes some PHI arguments as it's redirecting some edges, leaving a PHI 
with no arguments:

SR.33_23 = PHI <>

This should get cleaned up later, but the IPA polymorphic code gets 
called during the actual CFG clean-up, and walk_ssa_copies cannot handle 
an empty PHI.

Approved by Honza.

Fully tested on x86-64 Linux and verified that the patch fixes the ICE 
on an x86-64 Linux cross aarch64-linux-gnu cc1plus.

Committed to mainline.
-------------- next part --------------
commit cdb5a8f26178f61d6a2fdb2543f6c8b4c7136c94
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sun Mar 1 21:21:37 2015 -0800

    	PR middle-end/65233
    	* ipa-polymorphic-call.c (walk_ssa_copies): Handle empty PHIs.

diff --git a/gcc/ipa-polymorphic-call.c b/gcc/ipa-polymorphic-call.c
index aaa549e..13cc7f6 100644
--- a/gcc/ipa-polymorphic-call.c
+++ b/gcc/ipa-polymorphic-call.c
@@ -835,7 +835,10 @@ walk_ssa_copies (tree op, hash_set<tree> **global_visited = NULL)
 	{
 	  gimple phi = SSA_NAME_DEF_STMT (op);
 
-	  if (gimple_phi_num_args (phi) > 2)
+	  if (gimple_phi_num_args (phi) > 2
+	      /* We can be called while cleaning up the CFG and can
+		 have empty PHIs about to be removed.  */
+	      || gimple_phi_num_args (phi) == 0)
 	    goto done;
 	  if (gimple_phi_num_args (phi) == 1)
 	    op = gimple_phi_arg_def (phi, 0);


More information about the Gcc-patches mailing list