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] PR 40219, avoid accessing outside built_in_decls array when computing tree hashes


This is an updated version of my patch for bug 40219.  The bug is that I was
seeing segmentation violations on my power7-meissner branch when compiling some
of the spec benchmarks and tests in the testsuite with certain options.  The
bug would go away, depending on the options used.  Originally, I thought it was
something not being marked with the GTY(()) markers, but it turned out that the
bug was in machine independent code, in that the DECL_FUNCTION_CODE field is
overloaded, and the machine specific builtins do not correspond to the normal
builtins.  If an implementation has enough machine specific builtins, such as
the powerpc port does with the VSX instruction set changes, it can address
beyond the array.  Even if it doesn't go beyond the array limit, the code
wasn't right in that the function it was using for the hash wasn't the same
builtin function, and could have different arguments.

I did a full bootstrap/make check on my powerpc system with and without the
change, and there were no regressions.  On my power7-branch, this does fix the
one testsuite error and two spec builds that were failing.  Is this ok to check
in?

2009-05-21  Michael Meissner  <meissner@linux.vnet.ibm.com>

	PR tree-optimization/40219
	* decl.c (duplicate_decls): Make sure the builtin function is a
	normal builtin function before indexed into the built_in_decls
	array.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 147799)
+++ gcc/tree.c	(working copy)
@@ -5422,11 +5422,13 @@ iterative_hash_expr (const_tree t, hashv
 	return val;
       }
     case FUNCTION_DECL:
-      /* When referring to a built-in FUNCTION_DECL, use the
-	 __builtin__ form.  Otherwise nodes that compare equal
-	 according to operand_equal_p might get different
-	 hash codes.  */
-      if (DECL_BUILT_IN (t) && built_in_decls[DECL_FUNCTION_CODE (t)])
+      /* When referring to a built-in FUNCTION_DECL, use the __builtin__ form.
+	 Otherwise nodes that compare equal according to operand_equal_p might
+	 get different hash codes.  However, don't do this for machine specific
+	 or front end builtins, since the function code is overloaded in those
+	 cases.  */
+      if (DECL_BUILT_IN (t) && DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
+	  && built_in_decls[DECL_FUNCTION_CODE (t)])
 	{
 	  t = built_in_decls[DECL_FUNCTION_CODE (t)];
 	  code = TREE_CODE (t);

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com


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