This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa mudflap] dumping, writable-strings test
- From: "Frank Ch. Eigler" <fche at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 30 May 2003 13:30:35 -0400
- Subject: [tree-ssa mudflap] dumping, writable-strings test
Hi -
This patch contains a new test, and some dumping-related cleanup
that helped identify the problem.
--- gcc/ChangeLog.tree-ssa 29 May 2003 23:10:59 -0000 1.1.2.383
+++ gcc/ChangeLog.tree-ssa 30 May 2003 17:15:02 -0000
@@ -1,3 +1,8 @@
+2003-05-30 Frank Ch. Eigler <fche@redhat.com>
+
+ * tree-mudflap.c (mudflap_c_function, enqueue_constant, enqueue_decl):
+ Rework dumping logic.
+
Index: gcc/tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-mudflap.c,v
retrieving revision 1.1.2.41
diff -u -r1.1.2.41 tree-mudflap.c
--- gcc/tree-mudflap.c 16 May 2003 19:57:10 -0000 1.1.2.41
+++ gcc/tree-mudflap.c 30 May 2003 17:15:03 -0000
@@ -64,10 +64,6 @@
const char *, int));
static void mx_register_decls PARAMS ((tree, tree *));
-/* Debugging dumps. */
-static FILE *dump_file;
-static int dump_flags;
-
/* These macros are used to mark tree nodes, so that they are not
repeatedly transformed. The `bounded' flag is not otherwise used. */
@@ -83,9 +79,6 @@
mudflap_c_function (t)
tree t;
{
- /* Initialize debugging dumps. */
- dump_file = dump_begin (TDI_mudflap, &dump_flags);
-
mf_init_extern_trees ();
/* In multithreaded mode, don't cache the lookup cache parameters. */
@@ -100,11 +93,16 @@
is the single most expensive part of the tree-ssa path! */
simplify_function_tree (t);
- if (dump_file)
- {
- dump_end (TDI_mudflap, dump_file);
- dump_function (TDI_mudflap, t);
- }
+ {
+ FILE *dump_file;
+ int dump_flags;
+ dump_file = dump_begin (TDI_mudflap, &dump_flags);
+ if (dump_file)
+ {
+ dump_function (TDI_mudflap, t);
+ dump_end (TDI_mudflap, dump_file);
+ }
+ }
if (! (flag_mudflap > 1))
mf_decl_clear_locals ();
@@ -765,13 +763,6 @@
htab_t verboten = (htab_t) data;
tree tree_role;
- if (dump_flags & TDF_DETAILS)
- {
- fprintf (dump_file, "expr=%s: ", tree_code_name [TREE_CODE (*t)]);
- print_generic_expr (dump_file, *t, 0);
- fprintf (dump_file, "\n");
- }
-
/* Track lvalue/rvalue status for this subtree. */
if (! tree_roles_init)
{
@@ -1255,22 +1246,33 @@
return;
}
- if (dump_flags & TDF_DETAILS)
- {
- fprintf (dump_file, "enqueue_decl obj=`");
- print_generic_expr (dump_file, obj, 0);
- fprintf (dump_file, "' label=`%s'\n", label);
- }
-
if (COMPLETE_TYPE_P (TREE_TYPE (obj)))
{
+ FILE *dump_file;
+ int dump_flags;
+ tree object_size;
+ tree call_stmt;
+
+ object_size = size_in_bytes (TREE_TYPE (obj));
+
+ dump_file = dump_begin (TDI_mudflap, &dump_flags);
+ if (dump_file)
+ {
+ fprintf (dump_file, "enqueue_decl obj=`");
+ print_generic_expr (dump_file, obj, 0);
+ fprintf (dump_file, "' label=`%s' size=", label);
+ print_generic_expr (dump_file, object_size, 0);
+ fprintf (dump_file, "\n");
+ dump_end (TDI_mudflap, dump_file);
+ }
+
/* NB: the above condition doesn't require TREE_USED or
TREE_ADDRESSABLE. That's because this object may be a global
only used from other compilation units. XXX: Maybe static
objects could require those attributes being set. */
- tree call_stmt =
+ call_stmt =
mflang_register_call (label,
- size_in_bytes (TREE_TYPE (obj)),
+ object_size,
build_int_2 (4, 0), /* __MF_TYPE_STATIC */
mf_varname_tree (obj));
@@ -1313,19 +1315,38 @@
const char *label;
{
tree call_stmt;
+ tree object_size;
if (TREE_MUDFLAPPED_P (obj))
return;
+ object_size = (TREE_CODE (obj) == STRING_CST)
+ ? build_int_2 (TREE_STRING_LENGTH (obj), 0)
+ : size_in_bytes (TREE_TYPE (obj));
+
+ {
+ FILE *dump_file;
+ int dump_flags;
+
+ dump_file = dump_begin (TDI_mudflap, &dump_flags);
+ if (dump_file)
+ {
+ fprintf (dump_file, "enqueue_constant obj=`");
+ print_generic_expr (dump_file, obj, 0);
+ fprintf (dump_file, "' label=`%s' size=", label);
+ print_generic_expr (dump_file, object_size, 0);
+ fprintf (dump_file, "\n");
+ dump_end (TDI_mudflap, dump_file);
+ }
+ }
+
call_stmt =
(TREE_CODE (obj) == STRING_CST)
- ? mflang_register_call (label,
- build_int_2 (TREE_STRING_LENGTH (obj), 0),
+ ? mflang_register_call (label, object_size,
build_int_2 (4, 0), /* __MF_TYPE_STATIC */
mx_flag (fix_string_type
(build_string (15, "string literal"))))
- : mflang_register_call (label,
- size_in_bytes (TREE_TYPE (obj)),
+ : mflang_register_call (label, object_size,
build_int_2 (4, 0), /* __MF_TYPE_STATIC */
mx_flag (fix_string_type
(build_string (9, "constant"))));
--- libmudflap/ChangeLog 23 May 2003 21:27:37 -0000 1.1.2.57
+++ libmudflap/ChangeLog 30 May 2003 17:15:09 -0000
+2003-05-30 Frank Ch. Eigler <fche@redhat.com>
+
+ * testsuite/libmudflap.c/pass38-frag.c: New test for
+ -fwritable-strings.
+
Index: libmudflap/testsuite/libmudflap.c/pass38-frag.c
===================================================================
RCS file: libmudflap/testsuite/libmudflap.c/pass38-frag.c
diff -N libmudflap/testsuite/libmudflap.c/pass38-frag.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libmudflap/testsuite/libmudflap.c/pass38-frag.c 30 May 2003 17:15:09 -0000
@@ -0,0 +1,7 @@
+static const char *string[] = {"bla bla bla"};
+
+int main ()
+{
+ return (0);
+}
+/* { dg-options "-fwritable-strings -fmudflap" { target *-*-* } } */