Commit 3d377d6b authored by Matthias Braun's avatar Matthias Braun
Browse files

rework alias analysis options, remove global on/off switch in

The global switch is not necessary as the specific switches can express
the same options.
parent 2bcc254b
......@@ -100,12 +100,6 @@ FIRM_API void set_opt_global_cse(int value);
*/
FIRM_API void set_opt_global_null_ptr_elimination(int value);
/** Enable/Disable Alias analysis.
*
* If enabled, memory disambiguation by alias analysis is used.
*/
FIRM_API void set_opt_alias_analysis(int value);
/** Enable/Disable closed world assumption.
*
* If enabled, optimizations expect to know the "whole world", i.e. no
......
......@@ -38,14 +38,18 @@ typedef enum ir_entity_usage_computed_state {
} ir_entity_usage_computed_state;
/** Possible options for the memory disambiguator. */
typedef enum ir_disambuigator_options {
aa_opt_no_opt = 0, /**< no options: always assume aliasing */
aa_opt_type_based = 1, /**< use type based alias analysis: strict typed source language */
aa_opt_byte_type_may_alias = 2, /**< if type based analysis is enabled: bytes types may alias other types */
aa_opt_no_alias = 16, /**< two addresses NEVER alias, use with CAUTION (gcc -fno-alias) */
aa_opt_inherited = 128 /**< only for implementation: options from a graph are inherited from global */
} ir_disambuigator_options;
ENUM_BITSET(ir_disambuigator_options)
typedef enum ir_disambiguator_options {
aa_opt_none = 0, /**< no options, use defaults */
aa_opt_always_alias = 1u << 0, /**< always assume aliasing */
/**< use type based alias analysis: strictly typed source language */
aa_opt_type_based = 1u << 1,
/**< if type based analysis is enabled bytes types may alias other types */
aa_opt_byte_type_may_alias = 1u << 2,
aa_opt_no_alias = 1u << 3, /**< different addresses NEVER alias */
/**< internal flag: options from a graph are inherited from global */
aa_opt_inherited = 1u << 4,
} ir_disambiguator_options;
ENUM_BITSET(ir_disambiguator_options)
/**
* Returns a human readable name for an alias relation.
......@@ -130,7 +134,7 @@ FIRM_API void assure_irp_globals_entity_usage_computed(void);
*
* @param irg the graph
*/
FIRM_API unsigned get_irg_memory_disambiguator_options(const ir_graph *irg);
FIRM_API ir_disambiguator_options get_irg_memory_disambiguator_options(const ir_graph *irg);
/**
* Sets the memory disambiguator options for a graph.
......@@ -139,7 +143,7 @@ FIRM_API unsigned get_irg_memory_disambiguator_options(const ir_graph *irg);
* @param options a set of options
*/
FIRM_API void set_irg_memory_disambiguator_options(ir_graph *irg,
unsigned options);
ir_disambiguator_options options);
/**
* Sets the global disambiguator options for all graphs not having local
......@@ -147,7 +151,7 @@ FIRM_API void set_irg_memory_disambiguator_options(ir_graph *irg,
*
* @param options a set of options
*/
FIRM_API void set_irp_memory_disambiguator_options(unsigned options);
FIRM_API void set_irp_memory_disambiguator_options(ir_disambiguator_options options);
/**
* Mark all private methods, i.e. those of which all call sites are known.
......
......@@ -34,7 +34,7 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
DEBUG_ONLY(static firm_dbg_module_t *dbgcall = NULL;)
/** The global memory disambiguator options. */
static unsigned global_mem_disamgig_opt = aa_opt_no_opt;
static unsigned global_mem_disamgig_opt = aa_opt_none;
const char *get_ir_alias_relation_name(ir_alias_relation rel)
{
......@@ -238,15 +238,12 @@ static ir_alias_relation _get_alias_relation(
const ir_node *addr1, const ir_type *const type1,
const ir_node *addr2, const ir_type *const type2)
{
if (!get_opt_alias_analysis())
return ir_may_alias;
if (addr1 == addr2)
return ir_sure_alias;
ir_graph *const irg = get_irn_irg(addr1);
unsigned const options = get_irg_memory_disambiguator_options(irg);
if (options & aa_opt_always_alias)
return ir_may_alias;
/* The Armageddon switch */
if (options & aa_opt_no_alias)
return ir_no_alias;
......
......@@ -36,8 +36,5 @@ I_FLAG(algebraic_simplification , 4, ON)
/** Use Global Null Pointer Test elimination. */
I_FLAG(global_null_ptr_elimination , 5, ON)
/** Enable Alias-analysis. */
I_FLAG(alias_analysis , 11, ON)
/** Closed world assumption. */
I_FLAG(closed_world , 12, OFF)
......@@ -2171,8 +2171,7 @@ void optimize_load_store(ir_graph *irg)
assert(get_irg_pinned(irg) != op_pin_state_floats);
if (get_opt_alias_analysis())
assure_irp_globals_entity_usage_computed();
assure_irp_globals_entity_usage_computed();
walk_env_t env;
obstack_init(&env.obst);
......
......@@ -1753,9 +1753,7 @@ void opt_ldst(ir_graph *irg)
| IR_GRAPH_PROPERTY_NO_UNREACHABLE_CODE
| IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
if (get_opt_alias_analysis()) {
assure_irp_globals_entity_usage_computed();
}
assure_irp_globals_entity_usage_computed();
obstack_init(&env.obst);
ir_nodehashmap_init(&env.adr_map);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment