This is the mail archive of the
mailing list for the GCC project.
[incremental] Patch: FYI: handle re-builds
- From: Tom Tromey <tromey at redhat dot com>
- To: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 04 Oct 2007 10:36:08 -0600
- Subject: [incremental] Patch: FYI: handle re-builds
- Reply-to: Tom Tromey <tromey at redhat dot com>
I'm checking this in on the incremental compiler branch.
This patch fixes a couple miscellaneous bugs and also makes it
possible for re-builds to work. That is, "make; make clean; make"
works fine with the server now. (Well, "fine" -- we still emit an
incorrect warning when re-building.)
There were a few problems with this previously:
* When re-binding we were not passing function definitions to
* Decls for builtins were chained via their TREE_CHAIN, which was
overwritten when popping a scope.
* We were smashing decls that were put into the external scope.
* We need to re-register a smashed decl when re-binding.
I'm not happy with the details of this patch -- more for the cleanup
2007-10-04 Tom Tromey <email@example.com>
* c-decl.c (bind): Note a smash when needed.
(c_decl_re_bind): Pass function definitions to
(c_builtin_function): Don't use decl's TREE_CHAIN for
visible_builtins linked list.
(duplicate_decls): Also avoid smashing objects in external scope.
(start_function): Don't call c_parser_note_smash.
* toplev.c (start_as): Fix argv argument to pex_run.
--- toplev.c (revision 128925)
+++ toplev.c (working copy)
@@ -2205,7 +2205,7 @@
redeclared in a number of files. Yay. */
asm_out_file = pex_input_pipe (px, 0);
- errstr = pex_run (px, PEX_LAST | PEX_SEARCH, as_argv, as_argv + 1,
+ errstr = pex_run (px, PEX_LAST | PEX_SEARCH, as_argv, as_argv,
NULL, NULL, &pxerr);
--- c-decl.c (revision 128875)
+++ c-decl.c (working copy)
@@ -516,6 +516,10 @@
while (*here && (*here)->depth > scope->depth)
here = &(*here)->shadowed;
+ if (!notify_ok && *here && (*here)->depth == scope->depth
+ && B_IN_FILE_SCOPE (scope)) /* FIXME: zenity crash w/o this here... */
+ c_parser_note_smash ((*here)->decl, decl);
b->shadowed = *here;
*here = b;
@@ -540,8 +544,14 @@
TREE_ASM_WRITTEN (decl) = 0;
- if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
+ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
+ /* Function has already been genericized, so just tell cgraph
+ about it. */
+ cgraph_finalize_function (decl, false);
+ else if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
/* FIXME: moral equivalent of decl smashing here. */
if (DECL_INITIAL (decl) == NULL_TREE
|| DECL_INITIAL (decl) == error_mark_node)
@@ -942,7 +952,7 @@
- tree decl;
+ tree iter;
@@ -952,9 +962,15 @@
- for (decl = visible_builtins; decl; decl = TREE_CHAIN (decl))
- bind (DECL_NAME (decl), decl, file_scope,
- /*invisible=*/false, /*nested=*/true, /*notify_ok=*/true);
+ /* FIXME: some overlap between visible_builtins and all_c_built_ins.
+ Also, visible_builtins should probably be a set rather than using
+ tree_cons. */
+ for (iter = visible_builtins; iter; iter = TREE_CHAIN (iter))
+ tree decl = TREE_VALUE (iter);
+ bind (DECL_NAME (decl), decl, file_scope,
+ /*invisible=*/false, /*nested=*/true, /*notify_ok=*/true);
@@ -2085,7 +2101,12 @@
- if (B_IN_FILE_SCOPE (binding) && !object_in_current_hunk_p (olddecl))
+ /* Objects in any non-local scope have to be duplicated here,
+ since we do not want to smash any generally visible (and
+ reusable) decl. FIXME: should make just one duplicate for
+ both scopes. */
+ if ((B_IN_FILE_SCOPE (binding) || B_IN_EXTERNAL_SCOPE (binding))
+ && !object_in_current_hunk_p (olddecl))
/* Modify a copy of OLDDECL and install that in the
@@ -2096,6 +2117,7 @@
/* FIXME: this triggers building libgcc. */
/* gcc_assert (binding->decl == olddecl); */
binding->decl = copy;
+ c_parser_bind_callback (DECL_NAME (copy), copy);
c_parser_note_smash (olddecl, copy);
@@ -3076,8 +3098,9 @@
slot = htab_find_slot (all_c_built_ins, decl, INSERT);
*slot = decl;
- TREE_CHAIN (decl) = visible_builtins;
- visible_builtins = decl;
+ /* We use tree_cons here rather than the decl's TREE_CHAIN as
+ the latter is re-used when popping scopes. */
+ visible_builtins = tree_cons (NULL_TREE, decl, visible_builtins);
@@ -6497,10 +6520,7 @@
/* Record the decl so that the function name is defined.
If we already have a decl for this name, note that we smashed it. */
- old_decl = pushdecl (decl1);
- if (decl1 != old_decl)
- c_parser_note_smash (old_decl, decl1);
- current_function_decl = decl1;
+ current_function_decl = pushdecl (decl1);