From 9dc3782d2ec25dc5d1b6da4d686dfb77e9cbd317 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 1 Feb 2007 17:24:03 +0000 Subject: [PATCH] add local and parameter rule [r8581] --- ir/ana/irmemory.c | 39 ++++++++++++++++++++++++++++++++++++--- ir/ana/irmemory.h | 1 + 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/ir/ana/irmemory.c b/ir/ana/irmemory.c index c76464532..3c76a81de 100644 --- a/ir/ana/irmemory.c +++ b/ir/ana/irmemory.c @@ -132,6 +132,20 @@ static ir_alias_relation different_types(ir_node *adr1, ir_node *adr2) return may_alias; } /* different_types */ +/** + * Returns non-zero if a node is a routine parameter. + * + * @param node the node to test + */ +static int is_arg_Proj(ir_node *node) { + if (! is_Proj(node)) + return 0; + node = get_Proj_pred(node); + if (! is_Proj(node)) + return 0; + return is_Start(get_Proj_pred(node) && pn_Start_T_args == get_Proj_proj(node)); +} /* is_arg_Proj */ + /** * Determine the alias relation between two addresses. */ @@ -158,7 +172,7 @@ static ir_alias_relation _get_alias_relation( /* Two save some code, sort the addresses by its id's. Beware, this might break some things, so better check here. */ - assert(iro_SymConst < iro_Sel && "Code dependence breaked"); + assert(iro_SymConst < iro_Sel && iro_Sel < iro_Proj && "Code dependence breaked"); op1 = get_irn_opcode(adr1); op2 = get_irn_opcode(adr2); @@ -232,7 +246,14 @@ static ir_alias_relation _get_alias_relation( /* the second one is a TLS variable so they are always different (R1 d) */ return no_alias; + } else if (is_arg_Proj(base2)) { + /* the second one is an offset from a parameter so they are + always different (R1 e) */ + return no_alias; } + } else if (is_arg_Proj(adr2)) { + /* a local variable and a parameter are always different (R1 e) */ + return no_alias; } } else if (base1 == get_irg_tls(irg)) { /* the first is a TLS variable */ @@ -253,15 +274,27 @@ static ir_alias_relation _get_alias_relation( return different_offsets(adr1, adr2); } } + } else if (is_arg_Proj(base1)) { + /* the first one is an offset from a parameter */ + if (is_Sel(adr2)) { + /* the second address is a Sel */ + ir_node *base2 = find_base_adr(adr2, &ent2); + + if (base2 == get_irg_frame(irg)) { + /* the second one is a local variable so they are always + different (R1 e) */ + return no_alias; + } + } } } - if (options & aa_opt_type_based) { + if (options & aa_opt_type_based) { /* Type based alias analysis */ ir_alias_relation rel; if (options & aa_opt_byte_type_may_alias) { if (get_mode_size_bits(mode1) == 8 || get_mode_size_bits(mode2) == 8) { - /* One of the modes address a byte. Assume a may_alias ant leave + /* One of the modes address a byte. Assume a may_alias and leave the type based check. */ goto leave_type_based_alias; } diff --git a/ir/ana/irmemory.h b/ir/ana/irmemory.h index 794d7bace..70326346d 100644 --- a/ir/ana/irmemory.h +++ b/ir/ana/irmemory.h @@ -61,6 +61,7 @@ typedef ir_alias_relation (*DISAMBIGUATOR_FUNC)( * - a global variable and a local one never alias (R1 b) * - a global variable and a TLS one never alias (R1 c) * - a local variable and a TLS one never alias (R1 d) + * - a local variable and a parameter never alias (R1 e) * - two different variables never alias (R2) * - if one is a variable which address has never taken * there is no alias (R3) -- 2.20.1