* calls.c (mem_overlaps_already_clobbered_arg_p): Return true
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Feb 2007 13:52:46 +0000 (13:52 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 18 Feb 2007 13:52:46 +0000 (13:52 +0000)
for arg pointer based indexed addressing.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122095 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/tail_call.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/tail_call_p.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/tail_call_p.ads [new file with mode: 0644]

index c20044c..99b01ab 100644 (file)
@@ -1,3 +1,8 @@
+2007-02-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * calls.c (mem_overlaps_already_clobbered_arg_p): Return true
+       for arg pointer based indexed addressing.
+
 2007-02-18  Kazu Hirata  <kazu@codesourcery.com>
 
        * config/ia64/ia64.h, config/ia64/ia64.md,
index d84eb51..e65a2cc 100644 (file)
@@ -1481,10 +1481,14 @@ mem_overlaps_already_clobbered_arg_p (rtx addr, unsigned HOST_WIDE_INT size)
   if (addr == current_function_internal_arg_pointer)
     i = 0;
   else if (GET_CODE (addr) == PLUS
-          && (XEXP (addr, 0)
-              == current_function_internal_arg_pointer)
+          && XEXP (addr, 0) == current_function_internal_arg_pointer
           && GET_CODE (XEXP (addr, 1)) == CONST_INT)
     i = INTVAL (XEXP (addr, 1));
+  /* Return true for arg pointer based indexed addressing.  */
+  else if (GET_CODE (addr) == PLUS
+          && (XEXP (addr, 0) == current_function_internal_arg_pointer
+              || XEXP (addr, 1) == current_function_internal_arg_pointer))
+    return true;
   else
     return false;
 
index 05fdf91..13745a0 100644 (file)
@@ -1,5 +1,9 @@
 2007-02-18  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gnat.dg/tail_call_p.ads, tail_call_p.adb, tail_call.adb: New test.
+
+2007-02-18  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gnat.dg/test_prio_p.adb: Compile with -gnatws.
        * lib/gnat.exp (gnat_target_compile): Pass -f to the driver.
 
diff --git a/gcc/testsuite/gnat.dg/tail_call.adb b/gcc/testsuite/gnat.dg/tail_call.adb
new file mode 100644 (file)
index 0000000..4f109ad
--- /dev/null
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O2 -fno-unit-at-a-time" }
+
+with Tail_Call_P; use Tail_Call_P;
+
+procedure Tail_Call is
+begin
+  Insert (My_Array, 0, 0);
+end;
diff --git a/gcc/testsuite/gnat.dg/tail_call_p.adb b/gcc/testsuite/gnat.dg/tail_call_p.adb
new file mode 100644 (file)
index 0000000..56add5f
--- /dev/null
@@ -0,0 +1,35 @@
+package body Tail_Call_P is
+
+  function Start_Side (Element : T) return Index is
+  begin
+    if Element = 1 then
+      raise Program_Error;
+    end if;
+    if Element = 0 then
+      return Second;
+    else
+      return First;
+    end if;
+  end;
+
+  function Segment (Element : T) return T is
+  begin
+    if Element /= 0 then
+      raise Program_Error;
+    end if;
+    return 1;
+  end;
+
+  procedure Really_Insert (Into : T; Element : T; Value : T) is
+  begin
+    if Into /= 0 then
+      raise Program_Error;
+    end if;
+  end;
+
+  procedure Insert (Into : A; Element : T; Value : T) is
+  begin
+    Really_Insert (Into (Start_Side (Element)), Segment (Element), Value);
+  end Insert;
+
+end Tail_Call_P;
diff --git a/gcc/testsuite/gnat.dg/tail_call_p.ads b/gcc/testsuite/gnat.dg/tail_call_p.ads
new file mode 100644 (file)
index 0000000..1665bc3
--- /dev/null
@@ -0,0 +1,13 @@
+package Tail_Call_P is
+
+  type T is new Natural;
+
+  type Index is (First, Second);
+
+  type A is array (Index) of T;
+
+  My_Array : A := (0, 0);
+
+  procedure Insert (Into : A; Element : T; Value : T);
+
+end Tail_Call_P;