From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11560 invoked by alias); 12 Oct 2004 20:05:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 11525 invoked from network); 12 Oct 2004 20:05:38 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 12 Oct 2004 20:05:38 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i9CK5bM0019987; Tue, 12 Oct 2004 16:05:37 -0400 Received: from pobox.toronto.redhat.com (pobox.toronto.redhat.com [172.16.14.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9CK5br17135; Tue, 12 Oct 2004 16:05:37 -0400 Received: from touchme.toronto.redhat.com (IDENT:postfix@touchme.toronto.redhat.com [172.16.14.9]) by pobox.toronto.redhat.com (8.12.8/8.12.8) with ESMTP id i9CK5YbU027312; Tue, 12 Oct 2004 16:05:37 -0400 Received: from toenail.toronto.redhat.com (toenail.toronto.redhat.com [172.16.14.211]) by touchme.toronto.redhat.com (Postfix) with ESMTP id C0A8A8001BB; Tue, 12 Oct 2004 16:05:34 -0400 (EDT) Received: from toenail.toronto.redhat.com (localhost.localdomain [127.0.0.1]) by toenail.toronto.redhat.com (8.12.10/8.12.5) with ESMTP id i9CK5YBY031376; Tue, 12 Oct 2004 16:05:34 -0400 Received: (from fche@localhost) by toenail.toronto.redhat.com (8.12.10/8.12.10/Submit) id i9CK5YWP031374; Tue, 12 Oct 2004 16:05:34 -0400 Date: Tue, 12 Oct 2004 20:29:00 -0000 From: "Frank Ch. Eigler" To: gcc-patches@gcc.gnu.org Cc: dgraham@nortelnetworks.com Subject: [mudflap] timing of mudflap_finish vs. unaccessed global decls Message-ID: <20041012200534.GA31363@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i X-SW-Source: 2004-10/txt/msg01042.txt.bz2 Hi - As noticed by Doug Graham in , a bug sneaked into mudflap instrumentation of global variables. The bug came about from the callgraph code, which leaves processing of unreferenced global decls until too late. The following patch corrects this by in turn deferring the "mudflap_finish_file" call nearer the posterior of toplev.c's compile_file() function. This bootstraps on x86 and x86_64, but can someone confirm that this is about a good place for the call as any? - FChE 2004-10-12 Frank Ch. Eigler * toplev.c (compile_file): Call mudflap_finish_file from here ... * c-decl.c (c_write_global_declarations): ... instead of here ... * cp/decl.c (cp_finish_file): ... and here. * tree-mudflap.c (mudflap_enqueue_decl): Reword a warning message. Index: c-decl.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v retrieving revision 1.599 diff -u -w -s -p -r1.599 c-decl.c --- c-decl.c 10 Oct 2004 19:20:28 -0000 1.599 +++ c-decl.c 12 Oct 2004 19:54:25 -0000 @@ -7300,11 +7300,6 @@ c_write_global_declarations (void) /* We're done parsing; proceed to optimize and emit assembly. FIXME: shouldn't be the front end's responsibility to call this. */ cgraph_optimize (); - - /* Presently this has to happen after cgraph_optimize. - FIXME: shouldn't be the front end's responsibility to call this. */ - if (flag_mudflap) - mudflap_finish_file (); } #include "gt-c-decl.h" Index: toplev.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/toplev.c,v retrieving revision 1.927 diff -u -w -s -p -r1.927 toplev.c --- toplev.c 28 Sep 2004 20:34:17 -0000 1.927 +++ toplev.c 12 Oct 2004 19:54:26 -0000 @@ -80,6 +80,7 @@ Software Foundation, 59 Temple Place - S #include "coverage.h" #include "value-prof.h" #include "alloc-pool.h" +#include "tree-mudflap.h" #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) #include "dwarf2out.h" @@ -1004,6 +1005,10 @@ compile_file (void) functions in this compilation unit were deferred. */ coverage_finish (); + /* Likewise for mudflap static object registrations. */ + if (flag_mudflap) + mudflap_finish_file (); + /* Write out any pending weak symbol declarations. */ weak_finish (); Index: tree-mudflap.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/tree-mudflap.c,v retrieving revision 2.28 diff -u -w -s -p -r2.28 tree-mudflap.c --- tree-mudflap.c 2 Oct 2004 23:12:47 -0000 2.28 +++ tree-mudflap.c 12 Oct 2004 19:54:27 -0000 @@ -1215,7 +1215,7 @@ mudflap_enqueue_decl (tree obj) for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_static_decls); i++) if (VARRAY_TREE (deferred_static_decls, i) == obj) { - warning ("mudflap cannot track lifetime of %qs", + warning ("mudflap cannot track unknown size extern %qs", IDENTIFIER_POINTER (DECL_NAME (obj))); return; } Index: cp/decl2.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v retrieving revision 1.752 diff -u -w -s -p -r1.752 decl2.c --- cp/decl2.c 11 Oct 2004 16:59:23 -0000 1.752 +++ cp/decl2.c 12 Oct 2004 19:54:27 -0000 @@ -3066,11 +3066,6 @@ cp_finish_file (void) cgraph_finalize_compilation_unit (); cgraph_optimize (); - /* Emit mudflap static registration function. This must be done - after all the user functions have been expanded. */ - if (flag_mudflap) - mudflap_finish_file (); - /* Now, issue warnings about static, but not defined, functions, etc., and emit debugging information. */ walk_namespaces (wrapup_globals_for_namespace, /*data=*/&reconsider);