------- Comment #1 from baldrick at gcc dot gnu dot org 2010-07-05 18:43
-------
It turns out that the problem is that when build_function_type_skip_args
creates
the new type, TYPE_POINTER_TO for the new type is still pointing to the old
type.
When gimple_call_set_fndecl is used to change the fndecl to one with less
arguments, an ADDR_EXPR is built. The type of the ADDR_EXPR is obtained from
the
TYPE_POINTER_TO field of the new type, and thus has type pointer-to-old-type
rather than pointer-to-new-type. I'm testing the following patch. The idea
here is that calling copy_node has no advantage. In spite of the comment,
build_distinct_type_copy preserves attributes etc too, so it might as well
be used always. [I think the comment refers to some earlier logic, since
the change introducing build_distinct_type_copy post-dates it].
Index: gcc-4.5/gcc/tree.c
===================================================================
--- gcc-4.5.orig/gcc/tree.c 2010-07-05 20:26:21.349376337 +0200
+++ gcc-4.5/gcc/tree.c 2010-07-05 20:29:11.582730610 +0200
@@ -7208,24 +7208,10 @@
new_reversed = void_list_node;
}
- /* Use copy_node to preserve as much as possible from original type
- (debug info, attribute lists etc.)
- Exception is METHOD_TYPEs must have THIS argument.
- When we are asked to remove it, we need to build new FUNCTION_TYPE
- instead. */
- if (TREE_CODE (orig_type) != METHOD_TYPE
- || !bitmap_bit_p (args_to_skip, 0))
- {
- new_type = copy_node (orig_type);
- TYPE_ARG_TYPES (new_type) = new_reversed;
- }
- else
- {
- new_type
- = build_distinct_type_copy (build_function_type (TREE_TYPE
(orig_type),
- new_reversed));
- TYPE_CONTEXT (new_type) = TYPE_CONTEXT (orig_type);
- }
+ new_type
+ = build_distinct_type_copy (build_function_type (TREE_TYPE (orig_type),
+ new_reversed));
+ TYPE_CONTEXT (new_type) = TYPE_CONTEXT (orig_type);
/* This is a new type, not a copy of an old type. Need to reassociate
variants. We can handle everything except the main variant lazily. */
--
baldrick at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2010-07-05 18:43:39
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41355