[tuples] -fdump-tree-gimple-details
Aldy Hernandez
aldyh@redhat.com
Wed Jun 27 07:11:00 GMT 2007
On Tue, Jun 26, 2007 at 09:26:24PM -0400, Diego Novillo wrote:
> On 6/26/07 6:18 PM, Aldy Hernandez wrote:
>
> > Is something like this ok in the meantime?
>
> Sure. It should go out shortly, so it doesn't much matter how we deal
> with it for now.
>
> Thanks.
Now the testsuite works correctly. I'm not cleaning up the dump file,
because it's useful to have around for debugging (for now anyhow).
I've noticed we're broken in a few places, and generating incorrect code
in some others. This may be related to my modify_expr_rhs changes. I'm
pausing further changes on my end, while I fix the gimplifier to work
with the current tests. You don't need to do the same, since they're my
broken changes :-).
Committed to mainline.
* testsuite/gcc.dg/gimple/gimple.exp: Pass -fdump-tree-gimple-details
* testsuite/gcc.dg/gimple/compound_expr.c: Add dg-final.
* testsuite/gcc.dg/gimple/gs_return.c: Same.
* tree.h (gimplify_function_tree): Add return value.
* diagnostic.h (debug_c_tree): Move under tree-pretty-print.c section.
(dump_gimple_seq): New.
to tests.
* gimple-pretty-print.c (dump_gimple_seq): New.
* gimplify.c (gimplify_function_tree): Add return value.
Remove debug call and exit.
Comment out non-working code.
* c-gimplify.c (c_genericize): Dump gimple IR. Exit.
Index: testsuite/gcc.dg/gimple/gimple.exp
===================================================================
--- testsuite/gcc.dg/gimple/gimple.exp (revision 126013)
+++ testsuite/gcc.dg/gimple/gimple.exp (working copy)
@@ -21,7 +21,7 @@ load_lib gcc-dg.exp
# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
- set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+ set DEFAULT_CFLAGS " -ansi -pedantic-errors -fdump-tree-gimple-details"
}
# Initialize `dg'.
Index: testsuite/gcc.dg/gimple/compound_expr.c
===================================================================
--- testsuite/gcc.dg/gimple/compound_expr.c (revision 126013)
+++ testsuite/gcc.dg/gimple/compound_expr.c (working copy)
@@ -8,3 +8,5 @@ void foo()
{
a = (b, c);
}
+
+/* { dg-final { scan-tree-dump-times "gimpleir: a = c" 1 "gimple"} } */
Index: testsuite/gcc.dg/gimple/gs_return.c
===================================================================
--- testsuite/gcc.dg/gimple/gs_return.c (revision 126013)
+++ testsuite/gcc.dg/gimple/gs_return.c (working copy)
@@ -8,3 +8,5 @@ int foo()
{
return a + b;
}
+
+/* { dg-final { scan-tree-dump-times "gimpleir: return" 1 "gimple"} } */
Index: tree.h
===================================================================
--- tree.h (revision 126013)
+++ tree.h (working copy)
@@ -4737,7 +4737,7 @@ extern tree tree_overlaps_hard_reg_set (
/* In gimplify.c. */
extern tree create_artificial_label (void);
-extern void gimplify_function_tree (tree);
+extern struct gs_sequence gimplify_function_tree (tree);
extern const char *get_name (tree);
extern tree unshare_expr (tree);
extern void sort_case_labels (tree);
Index: diagnostic.h
===================================================================
--- diagnostic.h (revision 126013)
+++ diagnostic.h (working copy)
@@ -215,6 +215,7 @@ extern void print_generic_stmt_indented
extern void print_gimple_stmt (FILE *, gimple, int);
extern void print_generic_expr (FILE *, tree, int);
extern void print_generic_decl (FILE *, tree, int);
+extern void debug_c_tree (tree);
/* In gimple-pretty-print.c */
extern void debug_generic_expr (tree);
@@ -222,6 +223,6 @@ extern void debug_generic_stmt (tree);
extern void debug_tree_chain (tree);
extern void debug_gimple_stmt (gimple);
extern void debug_gimple_seq (gs_seq);
-extern void debug_c_tree (tree);
+extern void dump_gimple_seq (FILE *, gs_seq);
#endif /* ! GCC_DIAGNOSTIC_H */
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c (revision 126013)
+++ gimple-pretty-print.c (working copy)
@@ -82,6 +82,19 @@ debug_gimple_seq (gs_seq seq)
}
}
+void
+dump_gimple_seq (FILE *file, gs_seq seq)
+{
+ gimple_stmt_iterator i;
+
+ for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
+ {
+ gimple gs = gsi_stmt (i);
+ fprintf (file, "gimpleir: ");
+ print_gimple_stmt (file, gs, TDF_VOPS|TDF_MEMSYMS);
+ }
+}
+
/* Same, but for gimple statements. */
void
Index: gimplify.c
===================================================================
--- gimplify.c (revision 126013)
+++ gimplify.c (working copy)
@@ -6505,9 +6505,11 @@ gimplify_body (tree *body_p, gs_seq seq_
}
/* Entry point to the gimplification pass. FNDECL is the FUNCTION_DECL
- node for the function we want to gimplify. */
+ node for the function we want to gimplify.
+
+ Returns a gimple sequence. */
-void
+struct gs_sequence
gimplify_function_tree (tree fndecl)
{
tree oldfn, parm, ret;
@@ -6539,9 +6541,9 @@ gimplify_function_tree (tree fndecl)
gs_seq_init (&seq);
gimplify_body (&DECL_SAVED_TREE (fndecl), &seq, fndecl, true);
- debug_gimple_seq (&seq);
- exit (0);
+ /* FIXME tuples */
+#if 0
/* If we're instrumenting function entry/exit, then prepend the call to
the entry hook and wrap the whole function in a TRY_FINALLY_EXPR to
catch the exit hook. */
@@ -6568,10 +6570,12 @@ gimplify_function_tree (tree fndecl)
DECL_SAVED_TREE (fndecl) = bind;
}
+#endif
cfun->gimplified = true;
current_function_decl = oldfn;
cfun = oldfn ? DECL_STRUCT_FUNCTION (oldfn) : NULL;
+ return seq;
}
/* Expands EXPR to list of gimple statements STMTS. If SIMPLE is true,
Index: c-gimplify.c
===================================================================
--- c-gimplify.c (revision 126013)
+++ c-gimplify.c (working copy)
@@ -80,6 +80,7 @@ c_genericize (tree fndecl)
FILE *dump_orig;
int local_dump_flags;
struct cgraph_node *cgn;
+ struct gs_sequence seq;
/* Dump the C-specific tree IR. */
dump_orig = dump_begin (TDI_original, &local_dump_flags);
@@ -103,10 +104,23 @@ c_genericize (tree fndecl)
}
/* Go ahead and gimplify for now. */
- gimplify_function_tree (fndecl);
+ seq = gimplify_function_tree (fndecl);
- /* Dump the genericized tree IR. */
- dump_function (TDI_generic, fndecl);
+ dump_orig = dump_begin (TDI_generic, &local_dump_flags);
+ if (dump_orig)
+ {
+ /* Dump the genericized tree IR. */
+ dump_function_to_file (fndecl, dump_orig, local_dump_flags);
+
+ /* Dump the gimple IR. */
+ if (dump_orig && (local_dump_flags & TDF_DETAILS))
+ dump_gimple_seq (dump_orig, &seq);
+
+ dump_end (TDI_generic, dump_orig);
+ }
+
+ /* FIXME tuples. */
+ exit (0);
/* Genericize all nested functions now. We do things in this order so
that items like VLA sizes are expanded properly in the context of
More information about the Gcc-patches
mailing list