This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa mudflap] C++ tweaks


Hi -

The recent import of unit-at-a-time compilation broke one aspect
of C++ support for -fmudflap.  Globals were no longer registered
with the libmudflap runtime, like they were for C.  The patches
below correct this, and new test cases will catch regressions.

- FChE


[gcc]
2003-02-28  Frank Ch. Eigler  <fche at redhat dot com>

	* tree-mudflap.c (mudflap_enqueue_decl): Ignore extern artificial
	variable declarations.
[gcc/cp]
2003-02-28  Frank Ch. Eigler  <fche at redhat dot com>

	* decl2.c (finish_file): Adjust timing of mudflap_finish_file call
	to account for unit-at-a-time compilation.
[libmudflap]
2003-02-28  Frank Ch. Eigler  <fche at redhat dot com>

	* testsuite/libmudflap.c/fail23-frag.c, pass30-frag.c: New tests
	for global array registration.
	* testsuite/libmudflap.c++/fail24-frag.cxx, pass31-frag.cxx: Ditto.
	* testsuite/libmudflap.c++/c++frags.exp: Tweak -static multilib hack.


Index: tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.35
diff -u -p -r1.1.2.35 tree-mudflap.c
--- tree-mudflap.c	29 Jan 2003 17:46:33 -0000	1.1.2.35
+++ tree-mudflap.c	28 Feb 2003 19:37:04 -0000
@@ -1169,6 +1169,23 @@ mudflap_enqueue_decl (obj, label)
   if (TREE_MUDFLAPPED_P (obj))
     return;
 
+  /* We don't need to process variable decls that are internally
+     generated extern.  If we did, we'd end up with warnings for them
+     during mudflap_finish_file ().  That would confuse the user,
+     since the text would refer to variables that don't show up in the
+     user's source code.
+  */
+  if (DECL_P (obj) &&
+      DECL_EXTERNAL (obj) &&
+      DECL_ARTIFICIAL (obj))
+    {
+#if 0
+	warning_with_decl (obj, "ignoring system extern decl `%s'",
+			   IDENTIFIER_POINTER (DECL_NAME (obj)));
+#endif
+      return;
+    }
+
   /*
   fprintf (stderr, "enqueue_decl obj=`");
   print_generic_expr (stderr, obj, 0);
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.540.2.25
diff -u -p -r1.540.2.25 decl2.c
--- cp/decl2.c	23 Feb 2003 22:03:27 -0000	1.540.2.25
+++ cp/decl2.c	28 Feb 2003 19:37:06 -0000
@@ -2575,10 +2575,6 @@ finish_file ()
 
   emit_support_tinfos ();
 
-  /* Emit mudflap static registration function.  */
-  if (flag_mudflap)
-    mudflap_finish_file ();
-  
   do 
     {
       tree t;
@@ -2788,6 +2784,10 @@ finish_file ()
       
     }
   
+  /* Emit mudflap static registration function.  */
+  if (flag_mudflap)
+    mudflap_finish_file ();
+
   /* We give C linkage to static constructors and destructors.  */
   push_lang_context (lang_name_c);
 

Index: testsuite/libmudflap.c/fail23-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/fail23-frag.c
diff -N testsuite/libmudflap.c/fail23-frag.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libmudflap.c/fail23-frag.c	28 Feb 2003 19:43:26 -0000
***************
*** 0 ****
--- 1,16 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ char zoo [10];
+ 
+ int main ()
+ {
+ int i = strlen ("twelve") + strlen ("zero") + strlen ("seventeen");
+ zoo[i] = 'a';
+ return 0;
+ }
+ /* { dg-output "mudflap violation 1.*" } */
+ /* { dg-output "Nearby object.*" } */
+ /* { dg-output "mudflap object.*zoo.*static.*" } */
+ /* { dg-do run { xfail *-*-* } } */
Index: testsuite/libmudflap.c/pass30-frag.c
===================================================================
RCS file: testsuite/libmudflap.c/pass30-frag.c
diff -N testsuite/libmudflap.c/pass30-frag.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libmudflap.c/pass30-frag.c	28 Feb 2003 19:43:26 -0000
***************
*** 0 ****
--- 1,12 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ char zoo [10];
+ 
+ int main ()
+ {
+ int i = strlen ("eight") + strlen ("one");
+ zoo[i] = 'a';
+ return 0;
+ }
Index: testsuite/libmudflap.c++/c++frags.exp
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/testsuite/libmudflap.c++/Attic/c++frags.exp,v
retrieving revision 1.1.2.1
diff -c -r1.1.2.1 c++frags.exp
*** testsuite/libmudflap.c++/c++frags.exp	26 Feb 2003 19:00:38 -0000	1.1.2.1
--- testsuite/libmudflap.c++/c++frags.exp	28 Feb 2003 19:43:26 -0000
***************
*** 6,19 ****
  global srcdir
  
  # XXX: As of 2003-02-25, non-static linking of libstdc++ doesn't work with -fmudflap.
! foreach flags [list {} {-static} {-O2} {-O3}] {
      foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*.cxx]] {
  	set bsrc [file tail $srcfile]
! 	
! 	# XXX: The following hack makes instrumented programs run anyway
! 	setenv MUDFLAP_OPTIONS "-heur-proc-map -no-heur-argv-environ -viol-segv"
! 	# setenv MUDFLAP_OPTIONS "-no-heur-proc-map -no-heur-argv-environ -viol-segv"
! 
  	dg-runtest $srcfile $flags "-fmudflap"
      }
  }
--- 6,17 ----
  global srcdir
  
  # XXX: As of 2003-02-25, non-static linking of libstdc++ doesn't work with -fmudflap.
! # libstdc++ startup routines call into hooked str*/mem* functions, which fail due
! # to the disabled heuristics.
! foreach flags [list {-static} {-O3 -static}] {
      foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*.cxx]] {
  	set bsrc [file tail $srcfile]
! 	setenv MUDFLAP_OPTIONS "-no-heur-proc-map -no-heur-argv-environ -viol-segv"
  	dg-runtest $srcfile $flags "-fmudflap"
      }
  }
Index: testsuite/libmudflap.c++/fail24-frag.cxx
===================================================================
RCS file: testsuite/libmudflap.c++/fail24-frag.cxx
diff -N testsuite/libmudflap.c++/fail24-frag.cxx
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libmudflap.c++/fail24-frag.cxx	28 Feb 2003 19:43:26 -0000
***************
*** 0 ****
--- 1,16 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ char zoo [10];
+ 
+ int main ()
+ {
+ int i = strlen ("twelve") + strlen ("zero") + strlen ("seventeen");
+ zoo[i] = 'a';
+ return 0;
+ }
+ /* { dg-output "mudflap violation 1.*" } */
+ /* { dg-output "Nearby object.*" } */
+ /* { dg-output "mudflap object.*zoo.*static.*" } */
+ /* { dg-do run { xfail *-*-* } } */
Index: testsuite/libmudflap.c++/pass31-frag.cxx
===================================================================
RCS file: testsuite/libmudflap.c++/pass31-frag.cxx
diff -N testsuite/libmudflap.c++/pass31-frag.cxx
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libmudflap.c++/pass31-frag.cxx	28 Feb 2003 19:43:26 -0000
***************
*** 0 ****
--- 1,12 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ char zoo [10];
+ 
+ int main ()
+ {
+ int i = strlen ("eight") + strlen ("one");
+ zoo[i] = 'a';
+ return 0;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]