From 5b25a09b309b97b22a435ac82504c5d507e59093 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 10 Apr 2006 13:04:41 +0000 Subject: [PATCH] Fixed be_Return simulation: pop the stack only if floating point values are returned --- ir/be/ia32/ia32_x87.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ir/be/ia32/ia32_x87.c b/ir/be/ia32/ia32_x87.c index 85b915e39..1e4b0a17d 100644 --- a/ir/be/ia32/ia32_x87.c +++ b/ir/be/ia32/ia32_x87.c @@ -993,6 +993,7 @@ static void sim_store(x87_state *state, ir_node *n, const arch_env_t *env, ir_op unsigned live = vfp_liveness_nodes_live_at(env, n); op2_idx = x87_on_stack(state, arch_register_get_index(op2)); + assert(op2_idx >= 0); DB((dbg, LEVEL_1, ">>> %s %s ->\n", get_irn_opname(n), arch_register_get_name(op2))); @@ -1092,7 +1093,7 @@ static void sim_fCondJmp(x87_state *state, ir_node *n, const arch_env_t *env) { DB((dbg, LEVEL_1, ">>> %s %s, %s\n", get_irn_opname(n), arch_register_get_name(op2), arch_register_get_name(op1))); - DEBUG_ONLY(vfp_dump_live(live)); + DEBUG_ONLY(vfp_dump_live(live)); op2_idx = x87_on_stack(state, arch_register_get_index(op2)); @@ -1402,8 +1403,21 @@ static void sim_Reload(x87_state *state, ir_node *n, const arch_env_t *env) { * @param env the architecture environment */ static void sim_Return(x87_state *state, ir_node *n, const arch_env_t *env) { - assert(x87_get_depth(state) == 1); - x87_pop(state); + int n_res = be_Return_get_n_rets(n); + int i, n_float_res = 0; + + /* only floating point return values must resist on stack */ + for (i = 0; i < n_res; ++i) { + ir_node *res = get_irn_n(n, be_pos_Return_val + i); + + if (mode_is_float(get_irn_mode(res))) + ++n_float_res; + } + assert(x87_get_depth(state) == n_float_res); + + /* pop them virtually */ + for (i = n_float_res - 1; i >= 0; --i) + x87_pop(state); } /** -- 2.20.1