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]

[patch] Fix ICE in insert_clobber_before_stack_restore


Hi,

this is a regression present on mainline and 4.8 branch (and latent on the 4.7 
branch), which is visible with the attached Ada testcase for targets using the 
SJLJ exception scheme:

eric@polaris:~/gnat/bugs/M823-029> ~/build/gcc-4_8-branch/native/gcc/gnat1 -
quiet p.adb -O2
+===========================GNAT BUG DETECTED==============================+
| 4.8.2 20130916 (prerelease) [gcc-4_8-branch revision 202625] (x86_64-suse-
linux) GCC error:|
| in insert_clobber_before_stack_restore, at tree-ssa-ccp.c:1711           |
| Error detected around p.adb:5:3            

The problem is that insert_clobber_before_stack_restore recurses on PHI nodes, 
but stops on copy assignment statements, which appears to be just an oversight 
in this new function.  The SSA_NAMEs have SSA_NAME_OCCURS_IN_ABNORMAL_PHI here 
(because of the SJLJ exception scheme), which very likely explains the copy 
assignment statement.

Tested on x86_64-suse-linux, OK for mainline and 4.8 branch?  What about the 
4.7 branch?


2013-09-18  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-ssa-ccp.c (insert_clobber_before_stack_restore): Recurse on copy
	assignment statements.


2013-09-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/opt28.ad[sb]: New test.
	* gnat.dg/opt28_pkg.ads: New helper.


-- 
Eric Botcazou
Index: tree-ssa-ccp.c
===================================================================
--- tree-ssa-ccp.c	(revision 202588)
+++ tree-ssa-ccp.c	(working copy)
@@ -1728,6 +1728,9 @@ insert_clobber_before_stack_restore (tre
 	insert_clobber_before_stack_restore (gimple_phi_result (stmt), var,
 					     visited);
       }
+    else if (gimple_assign_ssa_name_copy_p (stmt))
+      insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
+					   visited);
     else
       gcc_assert (is_gimple_debug (stmt));
 }
with Opt28_Pkg; use Opt28_Pkg;

package body Opt28 is

  function Full_Filename (Filename : String) return String is
    Path : constant String := "PATH";
    Posix_Path : constant Posix_String := To_Posix (Path);
  begin

    declare
      M : constant Posix_String := Value_Of (Posix_Path);
      N : constant Posix_String (1 .. M'Length) := M;
      Var : constant String := To_String (Str => N);
      Start_Pos : Natural := 1;
      End_Pos   : Natural := 1;
    begin
      while Start_Pos <= Var'Length loop
        End_Pos := Position (Var (Start_Pos .. Var'Length));

        if Is_File (To_Posix (Var (Start_Pos .. End_Pos - 1) & Filename)) then
          return Var (Start_Pos .. End_Pos - 1) & Filename;
        else
          Start_Pos := End_Pos + 1;
        end if;
      end loop;
    end;

    return "";
  end;

end Opt28;
-- { dg-do compile }
-- { dg-options "-O2" }

package Opt28 is

  function Full_Filename (Filename : String) return String;

end Opt28;
package Opt28_Pkg is

  type Posix_String is array (Positive range <>) of aliased Character;

  function To_Posix (Str : String) return Posix_String;
  function To_String (Str : Posix_String) return String;
  function Is_File (Str : Posix_String) return Boolean;
  function Value_Of (Name : Posix_String) return Posix_String;
  function Position (In_Line : String) return Natural;

end Opt28_Pkg;

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