aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-23 22:28:49 +0000
committergsvelto <gsvelto@138bc75d-0d04-0410-961f-82ee72b054a4>2009-04-23 22:28:49 +0000
commit68d9d1253c8a08a65504f56fd25392ebe75c9584 (patch)
tree70f8e1c1f47a2aba0d17d2e0b7d16c31e7688b98
parenta2e2e840e084e0b61fb2a6b234537c922398634f (diff)
The dummy return variables created for pre-C99 non-void return functions with
void return statements are now flagged with the 'init' directive so that they are properly initialized by the CLI runtime. This fixes a problem with version 2.4 of Mono which bails out with an assertion upon encountering an uninitialized variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/st/cli-be@146658 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/config/cil32/cil-types.h1
-rw-r--r--gcc/config/cil32/cil32.c1
-rw-r--r--gcc/config/cil32/emit-cil.c5
-rw-r--r--gcc/config/cil32/gimple-to-cil.c9
4 files changed, 15 insertions, 1 deletions
diff --git a/gcc/config/cil32/cil-types.h b/gcc/config/cil32/cil-types.h
index 9b537645775..f8c937dcab3 100644
--- a/gcc/config/cil32/cil-types.h
+++ b/gcc/config/cil32/cil-types.h
@@ -337,6 +337,7 @@ struct machine_function GTY(())
{
unsigned int label_id;
tree label_addrs;
+ bool locals_init;
/* Hash table used for mapping CIL sequences to GCC's basic blocks. */
struct htab * GTY ((param_is (struct cil_basic_block_d))) bb_seqs;
diff --git a/gcc/config/cil32/cil32.c b/gcc/config/cil32/cil32.c
index 1dbfe3beeaa..4781d749f2d 100644
--- a/gcc/config/cil32/cil32.c
+++ b/gcc/config/cil32/cil32.c
@@ -119,6 +119,7 @@ cil_init_machine_status (void)
machine->label_id = 0;
machine->label_addrs = NULL_TREE;
+ machine->locals_init = false;
machine->bb_seqs = htab_create_ggc (32, cil_basic_block_hash,
cil_basic_block_eq, NULL);
diff --git a/gcc/config/cil32/emit-cil.c b/gcc/config/cil32/emit-cil.c
index a4b2be5b974..12d26470eca 100644
--- a/gcc/config/cil32/emit-cil.c
+++ b/gcc/config/cil32/emit-cil.c
@@ -2247,7 +2247,10 @@ emit_local_vars (FILE *file)
/* Emit the local variables starting from the most used ones. */
- fprintf (file, "\n\t.locals (");
+ if (cfun->machine->locals_init)
+ fprintf (file, "\n\t.locals init (");
+ else
+ fprintf (file, "\n\t.locals (");
for (i = 0; i < locals_n; i++)
{
diff --git a/gcc/config/cil32/gimple-to-cil.c b/gcc/config/cil32/gimple-to-cil.c
index a4ddaeda438..7b05aa853d6 100644
--- a/gcc/config/cil32/gimple-to-cil.c
+++ b/gcc/config/cil32/gimple-to-cil.c
@@ -3134,6 +3134,10 @@ gimple_to_cil_node (cil_stmt_iterator *csi, tree node)
stmt = cil_build_stmt_arg (CIL_LDLOC, res_var);
csi_insert_after (csi, stmt, CSI_CONTINUE_LINKING);
+
+ /* Flag the function so that the emission phase will emit an 'init'
+ directive in the local variables declaration. */
+ cfun->machine->locals_init = true;
}
stmt = cil_build_stmt (CIL_RET);
@@ -3456,6 +3460,11 @@ gimple_to_cil (void)
stmt = cil_build_stmt (CIL_RET);
csi_insert_after (&csi, stmt, CSI_CONTINUE_LINKING);
+
+ /* Flag the function so that the emission phase will emit an
+ 'init' directive in the local variables declaration. */
+ cfun->machine->locals_init = true;
+
/* FIXME: Is this really needed? */
make_single_succ_edge (bb, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
}