This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix ICE with dangling abnormal call edges


> OK, I'll add it and retest, thanks.

That worked fine so I've installed it.

However, as the attached testcase demonstrates, dangling abnormal call edges 
may be pre-existing, when local-pure-const discovers that a function is pure.
So the attached patch is also needed.  OK for mainline after full testing?


2010-10-20  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-optimize.c (execute_fixup_cfg): Purge dead abnormal call edges
	if there is a call statement to pure or const function in the block.


-- 
Eric Botcazou
Index: tree-optimize.c
===================================================================
--- tree-optimize.c	(revision 165574)
+++ tree-optimize.c	(working copy)
@@ -271,13 +271,16 @@ execute_fixup_cfg (void)
 	      int flags = gimple_call_flags (stmt);
 	      if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE))
 		{
+		  if (gimple_purge_dead_abnormal_call_edges (bb))
+		    todo |= TODO_cleanup_cfg;
+
 		  if (gimple_in_ssa_p (cfun))
 		    {
 		      todo |= TODO_update_ssa | TODO_cleanup_cfg;
 		      update_stmt (stmt);
 		    }
 		}
-	      
+
 	      if (flags & ECF_NORETURN
 		  && fixup_noreturn_call (stmt))
 		todo |= TODO_cleanup_cfg;
with Atree;    use Atree;
with Einfo;    use Einfo;
with Exp_Util; use Exp_Util;
with Nlists;   use Nlists;
with Nmake;    use Nmake;
with Rtsfind;  use Rtsfind;
with Sinfo;    use Sinfo;
with Tbuild;   use Tbuild;

package body Exp_Ch4 is

   procedure Expand_N_Allocator (N : Node_Id) is
      PtrT  : constant Entity_Id  := Etype (N);
      Loc   : constant Source_Ptr := Sloc (N);
      T : constant Entity_Id := Entity (Expression (N));
      Args, Decls : List_Id;
      Arg1, Decl, Temp_Decl : Node_Id;
      Temp  : Entity_Id;

   begin

      Temp := Make_Temporary (Loc, 'P');

      Arg1 :=
        Make_Explicit_Dereference (Loc,
          Prefix => New_Reference_To (Temp, Loc));

      Args := New_List (Arg1);

      if Has_Task (T) then
         if Nkind (Parent (N)) = N_Assignment_Statement then
            declare
               Nam : constant Node_Id := Name (Parent (N));

            begin
               if Is_Entity_Name (Nam) then
                  Decls :=
                    Build_Task_Image_Decls
                      (Loc,
                       New_Occurrence_Of
                         (Entity (Nam), Sloc (Nam)), T);

               else
                  Decls := Build_Task_Image_Decls (Loc, T, T);
               end if;
            end;

         elsif Nkind (Parent (N)) = N_Object_Declaration then
            Decls :=
              Build_Task_Image_Decls
                (Loc, Defining_Identifier (Parent (N)), T);

         else
            Decls := Build_Task_Image_Decls (Loc, T, T);
         end if;
      end if;

      Temp_Decl :=
        Make_Object_Declaration (Loc,
          Defining_Identifier => Temp,
          Constant_Present    => True,
          Object_Definition   => New_Reference_To (PtrT, Loc),
          Expression          => N);

      Insert_Action (N, Temp_Decl, Suppress => All_Checks);

   exception
      when RE_Not_Available => return;
   end Expand_N_Allocator;

end Exp_Ch4;
with Types; use Types;

package Exp_Ch4 is

   procedure Expand_N_Allocator (N : Node_Id);

end Exp_Ch4;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]