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 is_gimple_tmp_var properly


This patch should fix Richard Kenner's Ada problem (and likely other
unrecognized problems too).

Slightly revised version.  (Fixed stupid typo relative to last version.)
Finished complete bootstrap (without Ada), no changes in test results.

If we could pin down what the meaning actually *is* (beyond
DECL_ARTIFICIAL), the flag could probably be made more generic and used
on other things in future, and so be less of a "waste".
I think it means something approximating "This variable is in SSA form
throughout this function compilation", which could be useful for incremental
"partly-SSA-to-SSA" updates, but I'm not sure about that.

It appears, after extensive discussion, that we really don't have any
flags with the right meaning.  TREE_READONLY, TREE_CONSTANT, TREE_INVARIANT
all need to be false for some (many) temporaries.

In fact, I ran through all the existing bits for DECLs and none of them
seem to have appropriate semantics.  There might be a bit which is unused
for VAR_DECL which we could give two meanings, but (a) I didn't find one,
and (b) this seems a *lot* cleaner.  There could similarly be an unused
combination of bits, but again I didn't find one and that would be uglier,
and quite possibly slower.

Note that I left in the checks to the other things (DECL_ARTIFICIAL,
!TREE_STATIC, etc.) in anticipation of expanding the meaning; if the macro
will be used strictly for is_gimple_tmp_var, I could remove them.

This implementation isn't actually a waste of memory at all (since it goes in
former padding) and is just as fast as other bits which could be used.  It
eats into the bit space, but it currently seems unavoidable.

If it's kept restricted to these two uses (one set, one check), it can be
replaced with a fancier or cleverer system later if someone comes up with
one which actually works.

But correctness should come before microoptimization here.  If this solves
the Ada problem, I think it's worth committing it, as it certainly isn't
going to break anything and might well fix other things (at least it deals
with a FIXME)!  

So,
* Richard, could you test that this fixes the Ada problem (without
disabling DECL_ARTIFICAL in the front end)?
* If so, is this OK for mainline?

-- Long-Winded Nathanael

	* tree.h (struct tree_decl): Add gimple_tmp_var bit and
	macro to test it.
	* tree-gimple.c (is_gimple_tmp_var): Use the bit.
	* gimplify.c (create_tmp_var_raw): Set the bit.

Index: gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.62
diff -u -r2.62 gimplify.c
--- gimplify.c	12 Aug 2004 03:54:11 -0000	2.62
+++ gimplify.c	14 Aug 2004 01:40:55 -0000
@@ -326,6 +326,8 @@
   DECL_ARTIFICIAL (tmp_var) = 1;
   /* And we don't want debug info for it.  */
   DECL_IGNORED_P (tmp_var) = 1;
+  /* It has certain guaranteed properties due to the way we generated it. */
+  DECL_GIMPLE_TMP_VAR (tmp_var) = 1;
 
   /* Make the variable writable.  */
   TREE_READONLY (tmp_var) = 0;
Index: tree-gimple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-gimple.c,v
retrieving revision 2.21
diff -u -r2.21 tree-gimple.c
--- tree-gimple.c	12 Aug 2004 14:33:58 -0000	2.21
+++ tree-gimple.c	14 Aug 2004 01:40:57 -0000
@@ -450,7 +450,8 @@
 is_gimple_tmp_var (tree t)
 {
   /* FIXME this could trigger for other local artificials, too.  */
-  return (TREE_CODE (t) == VAR_DECL && DECL_ARTIFICIAL (t)
+  return (TREE_CODE (t) == VAR_DECL 
+          && DECL_ARTIFICIAL (t) && DECL_GIMPLE_TMP_VAR (t)
 	  && !TREE_STATIC (t) && !DECL_EXTERNAL (t));
 }
 
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.587
diff -u -r1.587 tree.h
--- tree.h	12 Aug 2004 14:34:01 -0000	1.587
+++ tree.h	14 Aug 2004 01:41:01 -0000
@@ -2167,6 +2167,13 @@
 #define DECL_POSSIBLY_INLINED(DECL) \
   FUNCTION_DECL_CHECK (DECL)->decl.possibly_inlined
 
+/* Nonzero for a decl which is a GIMPLE temporary variable.  These
+   are always DECL_ARTIFICAL, but also have other known and required
+   properties (which are slightly hard to describe). */
+
+#define DECL_GIMPLE_TMP_VAR(DECL) \
+  VAR_DECL_CHECK (DECL)->decl.gimple_tmp_var
+
 /* Enumerate visibility settings.  */
 #ifndef SYMBOL_VISIBILITY_DEFINED
 #define SYMBOL_VISIBILITY_DEFINED
@@ -2234,7 +2241,8 @@
   unsigned lang_flag_7 : 1;
 
   unsigned possibly_inlined : 1;
-  /* 15 unused bits.  */
+  unsigned gimple_tmp_var : 1;
+  /* 14 unused bits.  */
 
   union tree_decl_u1 {
     /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is

-- 
This space intentionally left blank.


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