This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/34982] [4.3 regression] calling a function with undefined parameters causes segmentation fault at -O1 or higher
- From: "hubicka at ucw dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Jan 2008 13:54:55 -0000
- Subject: [Bug target/34982] [4.3 regression] calling a function with undefined parameters causes segmentation fault at -O1 or higher
- References: <bug-34982-5606@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #6 from hubicka at ucw dot cz 2008-01-27 13:54 -------
Subject: Re: [4.3 regression] calling a function with undefined parameters
causes segmentation fault at -O1 or higher
cgraph_local_info still behaves as expected returning NULL when info is
not computed yet. Unfortunately check to simply ignore it when not
available has been added to ix86_function_regparm that makes this bug
lead to wrong code. (revision 123146)
There are two occurences where we can ix86_function_regparm. First one
is for compatibility checking, I would just declare it invalid - we
don't want the type comatiblity to depend on backend decision and I
think it is perfectly sane to reject any types specifying different
REGPARM values or where one specify and other doesn't.
I am testing attached patch and will commit it if passes.
Other case is from gimplifier, I am looking into it. This definitly has
to go or we need to drop the feature :(
Honza
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c (revision 131882)
+++ config/i386/i386.c (working copy)
@@ -3148,6 +3148,7 @@ ix86_comp_type_attributes (const_tree ty
{
/* Check for mismatch of non-default calling convention. */
const char *const rtdstr = TARGET_RTD ? "cdecl" : "stdcall";
+ tree attr1, attr2;
if (TREE_CODE (type1) != FUNCTION_TYPE
&& TREE_CODE (type1) != METHOD_TYPE)
@@ -3155,11 +3156,27 @@ ix86_comp_type_attributes (const_tree ty
/* Check for mismatched fastcall/regparm types. */
if ((!lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type1))
- != !lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type2)))
- || (ix86_function_regparm (type1, NULL)
- != ix86_function_regparm (type2, NULL)))
+ != !lookup_attribute ("fastcall", TYPE_ATTRIBUTES (type2))))
return 0;
+ /* We don't want to use ix86_function_regparm here: it's decision depends
+ on middle end information, like localness of functions. Here we only
want
+ to know if types are declared compatible. */
+ attr1 = lookup_attribute ("regparm", TYPE_ATTRIBUTES (type1));
+ attr2 = lookup_attribute ("regparm", TYPE_ATTRIBUTES (type2));
+
+ if ((attr1 != NULL_TREE) != (attr2 != NULL_TREE))
+ return 0;
+
+ if (attr1)
+ {
+ int val1 = TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr1)));
+ int val2 = TREE_INT_CST_LOW (TREE_VALUE (TREE_VALUE (attr2)));
+
+ if (val1 != val2)
+ return 0;
+ }
+
/* Check for mismatched sseregparm types. */
if (!lookup_attribute ("sseregparm", TYPE_ATTRIBUTES (type1))
!= !lookup_attribute ("sseregparm", TYPE_ATTRIBUTES (type2)))
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34982