This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] Use nth_parm_type in more_specialized_fn.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 14 Aug 2006 07:11:01 -0700
- Subject: [lto] Use nth_parm_type in more_specialized_fn.
Hi,
Attached is a patch to use nth_parm_type in more_specialized_fn.
more_specialized_fn skips several parameter types and may add a
parameter type before it does real work. Since nobody except
more_specialized_fn itself needs access to the effective parameter
type list that the real work happens on, this patch basically copies
incoming parameter lists to instances of VEC allocated in heap. The
actual work of comparing "specializedness" happens on the instances of
VEC.
Tested on x86_64-pc-linux-gnu. Committed to the LTO branch as
obvious.
Kazu Hirata
2006-08-14 Kazu Hirata <kazu@codesourcery.com>
* pt.c (more_specialized_fn): Use nth_parm_type.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 116122)
+++ cp/pt.c (working copy)
@@ -10846,6 +10846,12 @@ more_specialized_fn (tree pat1, tree pat
tree args2 = TYPE_ARG_TYPES (TREE_TYPE (decl2));
int better1 = 0;
int better2 = 0;
+ int skip1 = 0;
+ int skip2 = 0;
+ int orig_len;
+ int i;
+ VEC(tree,heap) *v1;
+ VEC(tree,heap) *v2;
/* Remove the this parameter from non-static member functions. If
one is a non-static member function and the other is not a static
@@ -10856,17 +10862,17 @@ more_specialized_fn (tree pat1, tree pat
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl1))
{
len--; /* LEN is the number of significant arguments for DECL1 */
- args1 = TREE_CHAIN (args1);
+ skip1++;
if (!DECL_STATIC_FUNCTION_P (decl2))
- args2 = TREE_CHAIN (args2);
+ skip2++;
}
else if (DECL_NONSTATIC_MEMBER_FUNCTION_P (decl2))
{
- args2 = TREE_CHAIN (args2);
+ skip2++;
if (!DECL_STATIC_FUNCTION_P (decl1))
{
len--;
- args1 = TREE_CHAIN (args1);
+ skip1++;
}
}
@@ -10874,20 +10880,30 @@ more_specialized_fn (tree pat1, tree pat
if (DECL_CONV_FN_P (decl1) != DECL_CONV_FN_P (decl2))
return 0;
- /* Consider the return type for a conversion function */
+ v1 = VEC_alloc (tree, heap, len + 1);
+ v2 = VEC_alloc (tree, heap, len + 1);
+
+ /* Consider the return type for a conversion function. */
+ orig_len = len;
if (DECL_CONV_FN_P (decl1))
{
- args1 = tree_cons (NULL_TREE, TREE_TYPE (TREE_TYPE (decl1)), args1);
- args2 = tree_cons (NULL_TREE, TREE_TYPE (TREE_TYPE (decl2)), args2);
+ VEC_quick_push (tree, v1, TREE_TYPE (TREE_TYPE (decl1)));
+ VEC_quick_push (tree, v2, TREE_TYPE (TREE_TYPE (decl2)));
len++;
}
+ for (i = 0; i < orig_len; i++)
+ {
+ VEC_quick_push (tree, v1, nth_parm_type (args1, skip1 + i));
+ VEC_quick_push (tree, v2, nth_parm_type (args2, skip2 + i));
+ }
+
processing_template_decl++;
- while (len--)
+ for (i = 0; i < len; i++)
{
- tree arg1 = TREE_VALUE (args1);
- tree arg2 = TREE_VALUE (args2);
+ tree arg1 = VEC_index (tree, v1, i);
+ tree arg2 = VEC_index (tree, v2, i);
int deduce1, deduce2;
int quals1 = -1;
int quals2 = -1;
@@ -10972,11 +10988,11 @@ more_specialized_fn (tree pat1, tree pat
better2 = 1;
if (deduce2 && !deduce1 && !better1)
better1 = 1;
-
- args1 = TREE_CHAIN (args1);
- args2 = TREE_CHAIN (args2);
}
+ VEC_free (tree, heap, v1);
+ VEC_free (tree, heap, v2);
+
processing_template_decl--;
return (better1 > 0) - (better2 > 0);