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: Fix PR c/7160


On Mon, Sep 23, 2002 at 02:12:43AM +0200, Eric Botcazou wrote:
> But it can't handle the following RTL configuration that the sched2 pass
> produces for the testcase:
> 
> (insn:HI 66 25 26 2 0x40156344 (clobber (reg/i:SF 8 st(0))) -1 (nil)
>     (expr_list:REG_UNUSED (reg/i:SF 8 st(0))
>         (nil)))
> 
> ...
> 
> (call_insn:TI 27 26 38 2 0x40156318 (set (reg:SI 0 eax)
>         (call (mem:QI (symbol_ref:SI ("foo1")) [0 S1 A8])
>             (const_int 8 [0x8]))) 496 {*call_value_0} (insn_list:REG_DEP_ANTI 25 (insn_list 24
> (insn_list 26 (nil))))
>     (nil)
>     (nil))
> 

I think that this is the actual bug.  The clobber insn should
depend on the call insn, and not get scheduled before it.

Fixed thus.


r~


        * sched-deps.c (sched_analyze_insn): Make clobber insns depend
        on call insns.

Index: sched-deps.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-deps.c,v
retrieving revision 1.47
diff -c -p -d -r1.47 sched-deps.c
*** sched-deps.c	8 Sep 2002 03:42:46 -0000	1.47
--- sched-deps.c	27 Sep 2002 01:06:53 -0000
*************** sched_analyze_insn (deps, x, insn, loop_
*** 922,928 ****
        code = GET_CODE (x);
      }
    if (code == SET || code == CLOBBER)
!     sched_analyze_1 (deps, x, insn);
    else if (code == PARALLEL)
      {
        int i;
--- 922,936 ----
        code = GET_CODE (x);
      }
    if (code == SET || code == CLOBBER)
!     {
!       sched_analyze_1 (deps, x, insn);
! 
!       /* Bare clobber insns are used for letting life analysis, reg-stack
! 	 and others know that a value is dead.  Depend on the last call
! 	 instruction so that reg-stack won't get confused.  */
!       if (code == CLOBBER)
! 	add_dependence_list (insn, deps->last_function_call, REG_DEP_OUTPUT);
!     }
    else if (code == PARALLEL)
      {
        int i;
Index: testsuite/gcc.c-torture/compile/20020926-1.c
===================================================================
RCS file: testsuite/gcc.c-torture/compile/20020926-1.c
diff -N testsuite/gcc.c-torture/compile/20020926-1.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/gcc.c-torture/compile/20020926-1.c	27 Sep 2002 01:06:55 -0000
***************
*** 0 ****
--- 1,21 ----
+ /* PR c/7160 */
+ /* Verify that the register-to-stack converter properly handles
+    branches without return value containing function calls.  */
+    
+ extern int gi;
+ 
+ extern int foo1(int, int);
+ extern void foo2(int, int);
+ extern float foo3(int);
+ 
+ float bar(int i1, int i2)
+ {
+   int i3;
+     
+   if (i2) {
+     i3 = foo1(i1, gi);
+     foo2(i1, i3);
+   }
+   else
+     return foo3(i2);
+ }


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