public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* A patch for CONST_DOUBLE
@ 1998-03-13 18:47 H.J. Lu
  1998-03-16 20:25 ` Jim Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 1998-03-13 18:47 UTC (permalink / raw)
  To: egcs

Hi,

I have to use this patch to make egcs generate correct asm code
on PPro. I don't understand the way force_const_mem () handles
CONST_DOUBLE in nested function. It doesn't look right to me.
When you force a double into memory, you have to assign a label
to the memory location even if it is in nested function. Otherwise,
force_const_mem () doesn't really do anything for nested function.
I will happen to resend a test case which I have sent to the egcs
list earlier.

BTW, if my patch is wrong, I would appreciate a test case to show it.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Fri Mar 13 18:40:57 1998  H.J. Lu  (hjl@gnu.org)

	* varasm.c (force_const_mem): Always update the label for
	CONST_DOUBLE even in nested function.
	(mark_constants): Enable searching inside a CONST_DOUBLE.

Index: varasm.c
===================================================================
RCS file: /home/work/cvs/gnu/egcs/gcc/varasm.c,v
retrieving revision 1.1.1.11
diff -u -p -r1.1.1.11 varasm.c
--- varasm.c	1998/03/12 17:18:41	1.1.1.11
+++ varasm.c	1998/03/14 02:35:18
@@ -3423,6 +3431,7 @@ force_const_mem (mode, x)
   CONSTANT_POOL_ADDRESS_P (XEXP (def, 0)) = 1;
   current_function_uses_const_pool = 1;
 
+#if 0
   if (outer_function_chain == 0)
     if (GET_CODE (x) == CONST_DOUBLE)
       {
@@ -3433,6 +3442,17 @@ force_const_mem (mode, x)
 	  }
 	CONST_DOUBLE_MEM (x) = def;
       }
+#else
+  if (GET_CODE (x) == CONST_DOUBLE)
+    {
+      if (outer_function_chain == 0 && CONST_DOUBLE_MEM (x) == cc0_rtx)
+	{
+	  CONST_DOUBLE_CHAIN (x) = const_double_chain;
+	  const_double_chain = x;
+	}
+      CONST_DOUBLE_MEM (x) = def;
+    }
+#endif
 
   return def;
 }
@@ -3625,6 +3645,7 @@ mark_constants (x)
 	find_pool_constant (x)->mark = 1;
       return;
     }
+#if 0
   /* Never search inside a CONST_DOUBLE, because CONST_DOUBLE_MEM may be
      a MEM, but does not constitute a use of that MEM.  This is particularly
      important inside a nested function, because CONST_DOUBLE_MEM may be
@@ -3632,6 +3653,7 @@ mark_constants (x)
      in force_const_mem.  */
   else if (GET_CODE (x) == CONST_DOUBLE)
     return;
+#endif
 
   /* Insns may appear inside a SEQUENCE.  Only check the patterns of
      insns, not any notes that may be attached.  We don't want to mark

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A patch for CONST_DOUBLE
  1998-03-13 18:47 A patch for CONST_DOUBLE H.J. Lu
@ 1998-03-16 20:25 ` Jim Wilson
  1998-03-17 11:27   ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Wilson @ 1998-03-16 20:25 UTC (permalink / raw)
  To: H.J. Lu; +Cc: egcs

This is mostly covered by other mail, but just to make it clear, this
patch is wrong.

You can not use outer_function_chain in a nested function, because this will
cause dangling pointers.  outer_function_chain is not saved/restored across
nested functions, so if you add object allocated in a nested function to
this variable, then the parent may end up trying to use them after they
have already been deallocated.

It is wrong to look at CONST_DOUBLE_MEM, because CONST_DOUBLE_MEM is an
internal field for the compiler's use, and does not indicate a reference
to a MEM (if it is a MEM).

Jim

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A patch for CONST_DOUBLE
  1998-03-17 11:27   ` H.J. Lu
@ 1998-03-17 11:27     ` Jim Wilson
  1998-03-17 11:33       ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Jim Wilson @ 1998-03-17 11:27 UTC (permalink / raw)
  To: H.J. Lu; +Cc: egcs

	I know. Have you looked at my latest patch?

You have posted so many messages with so many different subject lines that it
is not clear to me which patch is your latest patch.

The one that appears to be most recent still has the i386.md and varasm.c
changes which I mentioned yesterday were wrong.  However, it does have a
reg-stack.c patch added to it that might fix the problem I ran into.  I
will have to look at it later today and see if it helps.

Jim

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A patch for CONST_DOUBLE
  1998-03-16 20:25 ` Jim Wilson
@ 1998-03-17 11:27   ` H.J. Lu
  1998-03-17 11:27     ` Jim Wilson
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 1998-03-17 11:27 UTC (permalink / raw)
  To: Jim Wilson; +Cc: egcs

> 
> This is mostly covered by other mail, but just to make it clear, this
> patch is wrong.

I know. Have you looked at my latest patch?

> 
> You can not use outer_function_chain in a nested function, because this will
> cause dangling pointers.  outer_function_chain is not saved/restored across
> nested functions, so if you add object allocated in a nested function to
> this variable, then the parent may end up trying to use them after they
> have already been deallocated.
> 

That is exactly what happens, "dangling pointers", on PPro. Please
see the asm output of my 5 new PPro test cases.

Thanks.

-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: A patch for CONST_DOUBLE
  1998-03-17 11:27     ` Jim Wilson
@ 1998-03-17 11:33       ` H.J. Lu
  0 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 1998-03-17 11:33 UTC (permalink / raw)
  To: Jim Wilson; +Cc: egcs

> 
> 	I know. Have you looked at my latest patch?
> 
> You have posted so many messages with so many different subject lines that it
> is not clear to me which patch is your latest patch.
> 
> The one that appears to be most recent still has the i386.md and varasm.c
> changes which I mentioned yesterday were wrong.  However, it does have a
> reg-stack.c patch added to it that might fix the problem I ran into.  I
> will have to look at it later today and see if it helps.
> 

That is the one. My reg-stack.c plus your i386.md fix all the PPro
bugs I got.

BTW, I will send more test cases laters for PPro.

-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-03-17 11:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-13 18:47 A patch for CONST_DOUBLE H.J. Lu
1998-03-16 20:25 ` Jim Wilson
1998-03-17 11:27   ` H.J. Lu
1998-03-17 11:27     ` Jim Wilson
1998-03-17 11:33       ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).