Commit 429d687f authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Add ALLOCAN() and ALLOCANZ().

[r22985]
parent 38249b03
...@@ -79,6 +79,16 @@ char *xstrdup(const char *str); ...@@ -79,6 +79,16 @@ char *xstrdup(const char *str);
*/ */
#define XMALLOCFZ(type, member, n) ((type*)memset(xmalloc(offsetof(type, member) + sizeof(((type*)0)->member) * (n)), 0, offsetof(type, member) + sizeof(((type*)0)->member) * (n))) #define XMALLOCFZ(type, member, n) ((type*)memset(xmalloc(offsetof(type, member) + sizeof(((type*)0)->member) * (n)), 0, offsetof(type, member) + sizeof(((type*)0)->member) * (n)))
/**
* Allocate n objects of a certain type on the stack
*/
#define ALLOCAN(type, n) ((type*)alloca(sizeof(type) * (n)))
/**
* Allocate n objects of a certain type on the stack and zero them
*/
#define ALLOCANZ(type, n) ((type*)memset((type*)alloca(sizeof(type) * (n)), 0, sizeof(type) * (n)))
/* Includes for alloca() */ /* Includes for alloca() */
#if defined(__FreeBSD__) #if defined(__FreeBSD__)
......
...@@ -599,8 +599,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp) ...@@ -599,8 +599,7 @@ static ir_node *adjust_call(be_abi_irg_t *env, ir_node *irn, ir_node *curr_sp)
/* search the greatest result proj number */ /* search the greatest result proj number */
res_projs = alloca(n_res * sizeof(res_projs[0])); res_projs = ALLOCANZ(ir_node*, n_res);
memset(res_projs, 0, n_res * sizeof(res_projs[0]));
foreach_out_edge(irn, edge) { foreach_out_edge(irn, edge) {
const ir_edge_t *res_edge; const ir_edge_t *res_edge;
......
...@@ -534,10 +534,10 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, ...@@ -534,10 +534,10 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env,
n_regs = env->cls->n_regs; n_regs = env->cls->n_regs;
bs = bitset_alloca(n_regs); bs = bitset_alloca(n_regs);
alloc_nodes = alloca(n_regs * sizeof(alloc_nodes[0])); alloc_nodes = ALLOCAN(ir_node*, n_regs);
//bp = hungarian_new(n_regs, n_regs, 2, HUNGARIAN_MATCH_PERFECT); //bp = hungarian_new(n_regs, n_regs, 2, HUNGARIAN_MATCH_PERFECT);
bp = bipartite_new(n_regs, n_regs); bp = bipartite_new(n_regs, n_regs);
assignment = alloca(n_regs * sizeof(assignment[0])); assignment = ALLOCAN(int, n_regs);
partners = pmap_create(); partners = pmap_create();
/* /*
......
...@@ -429,7 +429,7 @@ static void be_ra_chordal_main(be_irg_t *birg) ...@@ -429,7 +429,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
/* the backend has its own spiller */ /* the backend has its own spiller */
m = arch_env_get_n_reg_class(arch_env); m = arch_env_get_n_reg_class(arch_env);
pse = alloca(m * sizeof(pse[0])); pse = ALLOCAN(post_spill_env_t, m);
for (j = 0; j < m; ++j) { for (j = 0; j < m; ++j) {
memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env)); memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
......
...@@ -390,11 +390,11 @@ static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) { ...@@ -390,11 +390,11 @@ static inline void qnode_max_ind_set(qnode_t *qn, const unit_t *ou) {
* safe: node has no interference, hence it is in every max stable set. * safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference * unsafe: node has an interference
*/ */
safe = alloca((ou->node_count-1) * sizeof(*safe)); safe = ALLOCAN(ir_node*, ou->node_count - 1);
safe_costs = 0; safe_costs = 0;
safe_count = 0; safe_count = 0;
unsafe = alloca((ou->node_count-1) * sizeof(*unsafe)); unsafe = ALLOCAN(ir_node*, ou->node_count - 1);
unsafe_costs = alloca((ou->node_count-1) * sizeof(*unsafe_costs)); unsafe_costs = ALLOCAN(int, ou->node_count - 1);
unsafe_count = 0; unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) { for(i=1; i<ou->node_count; ++i) {
int is_safe = 1; int is_safe = 1;
......
...@@ -530,7 +530,7 @@ static int change_color_not(co2_t *env, const ir_node *irn, col_t not_col, struc ...@@ -530,7 +530,7 @@ static int change_color_not(co2_t *env, const ir_node *irn, col_t not_col, struc
/* The node has the color it should not have _and_ has not been visited yet. */ /* The node has the color it should not have _and_ has not been visited yet. */
if(!color_is_fix(env, irn)) { if(!color_is_fix(env, irn)) {
int n_regs = env->co->cls->n_regs; int n_regs = env->co->cls->n_regs;
col_cost_pair_t *csts = alloca(n_regs * sizeof(csts[0])); col_cost_pair_t *csts = ALLOCAN(col_cost_pair_t, n_regs);
/* Get the costs for giving the node a specific color. */ /* Get the costs for giving the node a specific color. */
determine_color_costs(env, ci, csts); determine_color_costs(env, ci, csts);
...@@ -571,7 +571,7 @@ static int change_color_single(co2_t *env, const ir_node *irn, col_t tgt_col, st ...@@ -571,7 +571,7 @@ static int change_color_single(co2_t *env, const ir_node *irn, col_t tgt_col, st
if(!color_is_fix(env, irn) && is_color_admissible(env, ci, tgt_col)) { if(!color_is_fix(env, irn) && is_color_admissible(env, ci, tgt_col)) {
int n_regs = env->co->cls->n_regs; int n_regs = env->co->cls->n_regs;
col_cost_pair_t *seq = alloca(n_regs * sizeof(seq[0])); col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, n_regs);
/* Get the costs for giving the node a specific color. */ /* Get the costs for giving the node a specific color. */
single_color_cost(env, ci, tgt_col, seq); single_color_cost(env, ci, tgt_col, seq);
...@@ -696,7 +696,7 @@ static void unfix_subtree(co2_cloud_irn_t *ci) ...@@ -696,7 +696,7 @@ static void unfix_subtree(co2_cloud_irn_t *ci)
static int coalesce_top_down(co2_cloud_irn_t *ci, int child_nr, int depth) static int coalesce_top_down(co2_cloud_irn_t *ci, int child_nr, int depth)
{ {
co2_t *env = ci->cloud->env; co2_t *env = ci->cloud->env;
col_cost_pair_t *seq = alloca(env->n_regs * sizeof(seq[0])); col_cost_pair_t *seq = ALLOCAN(col_cost_pair_t, env->n_regs);
int is_root = ci->mst_parent == ci; int is_root = ci->mst_parent == ci;
col_t parent_col = is_root ? (col_t) -1 : get_col(env, ci->mst_parent->inh.irn); col_t parent_col = is_root ? (col_t) -1 : get_col(env, ci->mst_parent->inh.irn);
int min_badness = INT_MAX; int min_badness = INT_MAX;
......
...@@ -932,11 +932,12 @@ static inline int is_loose(co_mst_irn_t *node) ...@@ -932,11 +932,12 @@ static inline int is_loose(co_mst_irn_t *node)
/** /**
* Determines the costs for each color if it would be assigned to node @p node. * Determines the costs for each color if it would be assigned to node @p node.
*/ */
static void determine_color_costs(co_mst_env_t *env, co_mst_irn_t *node, col_cost_t *costs) { static void determine_color_costs(co_mst_env_t *env, co_mst_irn_t *node, col_cost_t *costs)
int *neigh_cols = alloca(env->n_regs * sizeof(*neigh_cols)); {
int n_loose = 0; int *neigh_cols = ALLOCAN(int, env->n_regs);
int n_loose = 0;
real_t coeff; real_t coeff;
int i; int i;
for (i = 0; i < env->n_regs; ++i) { for (i = 0; i < env->n_regs; ++i) {
neigh_cols[i] = 0; neigh_cols[i] = 0;
...@@ -981,7 +982,7 @@ static int change_node_color_excluded(co_mst_env_t *env, co_mst_irn_t *node, int ...@@ -981,7 +982,7 @@ static int change_node_color_excluded(co_mst_env_t *env, co_mst_irn_t *node, int
/* The node has the color it should not have _and_ has not been visited yet. */ /* The node has the color it should not have _and_ has not been visited yet. */
if (is_loose(node)) { if (is_loose(node)) {
col_cost_t *costs = alloca(env->n_regs * sizeof(costs[0])); col_cost_t *costs = ALLOCAN(col_cost_t, env->n_regs);
/* Get the costs for giving the node a specific color. */ /* Get the costs for giving the node a specific color. */
determine_color_costs(env, node, costs); determine_color_costs(env, node, costs);
...@@ -1149,7 +1150,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { ...@@ -1149,7 +1150,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) {
int n_int_chunks = 0; int n_int_chunks = 0;
waitq *tmp_chunks = new_waitq(); waitq *tmp_chunks = new_waitq();
waitq *best_starts = NULL; waitq *best_starts = NULL;
col_cost_t *order = alloca(env->n_regs * sizeof(order[0])); col_cost_t *order = ALLOCANZ(col_cost_t, env->n_regs);
bitset_t *visited; bitset_t *visited;
int idx, len, i, nidx, pos; int idx, len, i, nidx, pos;
struct list_head changed; struct list_head changed;
...@@ -1163,8 +1164,6 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { ...@@ -1163,8 +1164,6 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) {
++env->chunk_visited; ++env->chunk_visited;
/* compute color preference */ /* compute color preference */
memset(order, 0, env->n_regs * sizeof(order[0]));
for (pos = 0, len = ARR_LEN(c->interfere); pos < len; ++pos) { for (pos = 0, len = ARR_LEN(c->interfere); pos < len; ++pos) {
const ir_node *n = c->interfere[pos]; const ir_node *n = c->interfere[pos];
co_mst_irn_t *node = get_co_mst_irn(env, n); co_mst_irn_t *node = get_co_mst_irn(env, n);
......
...@@ -106,13 +106,15 @@ size_red_t *new_size_red(copy_opt_t *co) { ...@@ -106,13 +106,15 @@ size_red_t *new_size_red(copy_opt_t *co) {
/** /**
* Checks if a node is simplicial in the graph heeding the already removed nodes. * Checks if a node is simplicial in the graph heeding the already removed nodes.
*/ */
static inline int sr_is_simplicial(size_red_t *sr, const ir_node *ifn) { static inline int sr_is_simplicial(size_red_t *sr, const ir_node *ifn)
int i, o, size = 0; {
ir_node **all, *curr; be_ifg_t *ifg = sr->co->cenv->ifg;
be_ifg_t *ifg = sr->co->cenv->ifg; void *iter = be_ifg_neighbours_iter_alloca(ifg);
void *iter = be_ifg_neighbours_iter_alloca(ifg); ir_node **all = ALLOCAN(ir_node*, be_ifg_degree(ifg, ifn));
ir_node *curr;
all = alloca(be_ifg_degree(ifg, ifn) * sizeof(*all)); int size = 0;
int i;
int o;
/* get all non-removed neighbors */ /* get all non-removed neighbors */
be_ifg_foreach_neighbour(ifg, iter, ifn, curr) be_ifg_foreach_neighbour(ifg, iter, ifn, curr)
......
...@@ -125,16 +125,17 @@ static void build_coloring_cstr(ilp_env_t *ienv) { ...@@ -125,16 +125,17 @@ static void build_coloring_cstr(ilp_env_t *ienv) {
} }
} }
static void build_interference_cstr(ilp_env_t *ienv) { static void build_interference_cstr(ilp_env_t *ienv)
lpp_t *lpp = ienv->lp; {
local_env_t *lenv = ienv->env; lpp_t *lpp = ienv->lp;
be_ifg_t *ifg = ienv->co->cenv->ifg; local_env_t *lenv = ienv->env;
int n_colors = lenv->n_colors; be_ifg_t *ifg = ienv->co->cenv->ifg;
int i, col; int n_colors = lenv->n_colors;
void *iter = be_ifg_cliques_iter_alloca(ifg);
void *iter = be_ifg_cliques_iter_alloca(ifg); ir_node **clique = ALLOCAN(ir_node*, n_colors);
ir_node **clique = alloca(sizeof(*clique) * n_colors); int size;
int size; int col;
int i;
char buf[16]; char buf[16];
...@@ -414,8 +415,8 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn) { ...@@ -414,8 +415,8 @@ static void extend_path(ilp_env_t *ienv, pdeq *path, const ir_node *irn) {
/* check for forbidden interferences */ /* check for forbidden interferences */
len = pdeq_len(path); len = pdeq_len(path);
curr_path = alloca(len * sizeof(*curr_path)); curr_path = ALLOCAN(ir_node*, len);
pdeq_copyl(path, (const void **)curr_path); pdeq_copyl(path, (const void **)curr_path);
for (i=1; i<len; ++i) for (i=1; i<len; ++i)
......
...@@ -307,11 +307,11 @@ static int ou_max_ind_set_costs(unit_t *ou) { ...@@ -307,11 +307,11 @@ static int ou_max_ind_set_costs(unit_t *ou) {
* safe: node has no interference, hence it is in every max stable set. * safe: node has no interference, hence it is in every max stable set.
* unsafe: node has an interference * unsafe: node has an interference
*/ */
safe = alloca((ou->node_count-1) * sizeof(*safe)); safe = ALLOCAN(ir_node*, ou->node_count - 1);
safe_costs = 0; safe_costs = 0;
safe_count = 0; safe_count = 0;
unsafe = alloca((ou->node_count-1) * sizeof(*unsafe)); unsafe = ALLOCAN(ir_node*, ou->node_count - 1);
unsafe_costs = alloca((ou->node_count-1) * sizeof(*unsafe_costs)); unsafe_costs = ALLOCAN(int, ou->node_count - 1);
unsafe_count = 0; unsafe_count = 0;
for(i=1; i<ou->node_count; ++i) { for(i=1; i<ou->node_count; ++i) {
int is_safe = 1; int is_safe = 1;
...@@ -572,7 +572,7 @@ static void co_sort_units(copy_opt_t *co) { ...@@ -572,7 +572,7 @@ static void co_sort_units(copy_opt_t *co) {
/* get the number of ous, remove them form the list and fill the array */ /* get the number of ous, remove them form the list and fill the array */
list_for_each_entry(unit_t, ou, &co->units, units) list_for_each_entry(unit_t, ou, &co->units, units)
count++; count++;
ous = alloca(count * sizeof(*ous)); ous = ALLOCAN(unit_t, count);
costs = co_get_max_copy_costs(co); costs = co_get_max_copy_costs(co);
...@@ -861,9 +861,9 @@ static int co_dump_appel_disjoint_constraints(const copy_opt_t *co, ir_node *a, ...@@ -861,9 +861,9 @@ static int co_dump_appel_disjoint_constraints(const copy_opt_t *co, ir_node *a,
void co_dump_appel_graph(const copy_opt_t *co, FILE *f) void co_dump_appel_graph(const copy_opt_t *co, FILE *f)
{ {
be_ifg_t *ifg = co->cenv->ifg; be_ifg_t *ifg = co->cenv->ifg;
int *color_map = alloca(co->cls->n_regs * sizeof(color_map[0])); int *color_map = ALLOCAN(int, co->cls->n_regs);
int *node_map = XMALLOCN(int, get_irg_last_idx(co->irg) + 1); int *node_map = XMALLOCN(int, get_irg_last_idx(co->irg) + 1);
ir_node *irn; ir_node *irn;
void *it, *nit; void *it, *nit;
......
...@@ -291,7 +291,7 @@ static void lower_perm_node(ir_node *irn, lower_env_t *env) ...@@ -291,7 +291,7 @@ static void lower_perm_node(ir_node *irn, lower_env_t *env)
ir_graph *const irg = get_irn_irg(irn); ir_graph *const irg = get_irn_irg(irn);
ir_node *const block = get_nodes_block(irn); ir_node *const block = get_nodes_block(irn);
int const arity = get_irn_arity(irn); int const arity = get_irn_arity(irn);
reg_pair_t *const pairs = alloca(arity * sizeof(pairs[0])); reg_pair_t *const pairs = ALLOCAN(reg_pair_t, arity);
int keep_perm = 0; int keep_perm = 0;
int do_copy = env->do_copy; int do_copy = env->do_copy;
/* Get the schedule predecessor node to the perm. /* Get the schedule predecessor node to the perm.
...@@ -767,7 +767,6 @@ static void melt_copykeeps(constraint_env_t *cenv) { ...@@ -767,7 +767,6 @@ static void melt_copykeeps(constraint_env_t *cenv) {
void assure_constraints(be_irg_t *birg) { void assure_constraints(be_irg_t *birg) {
ir_graph *irg = be_get_birg_irg(birg); ir_graph *irg = be_get_birg_irg(birg);
constraint_env_t cenv; constraint_env_t cenv;
ir_node **nodes;
ir_nodemap_iterator_t map_iter; ir_nodemap_iterator_t map_iter;
ir_nodemap_entry_t map_entry; ir_nodemap_entry_t map_entry;
...@@ -786,15 +785,13 @@ void assure_constraints(be_irg_t *birg) { ...@@ -786,15 +785,13 @@ void assure_constraints(be_irg_t *birg) {
/* for all */ /* for all */
foreach_ir_nodemap(&cenv.op_set, map_entry, map_iter) { foreach_ir_nodemap(&cenv.op_set, map_entry, map_iter) {
op_copy_assoc_t *entry = map_entry.data; op_copy_assoc_t *entry = map_entry.data;
int n; int n = ir_nodeset_size(&entry->copies);
ir_node *cp; ir_node **nodes = ALLOCAN(ir_node*, n);
ir_nodeset_iterator_t iter; ir_node *cp;
ir_nodeset_iterator_t iter;
be_ssa_construction_env_t senv; be_ssa_construction_env_t senv;
n = ir_nodeset_size(&entry->copies);
nodes = alloca(n * sizeof(nodes[0]));
/* put the node in an array */ /* put the node in an array */
DBG((dbg_constr, LEVEL_1, "introduce copies for %+F ", map_entry.node)); DBG((dbg_constr, LEVEL_1, "introduce copies for %+F ", map_entry.node));
...@@ -966,8 +963,8 @@ found_front: ...@@ -966,8 +963,8 @@ found_front:
return 0; return 0;
} }
map = alloca(new_size * sizeof(map[0])); map = ALLOCAN(int, new_size);
proj_map = alloca(arity * sizeof(proj_map[0])); proj_map = ALLOCAN(int, arity);
memset(proj_map, -1, sizeof(proj_map[0])); memset(proj_map, -1, sizeof(proj_map[0]));
n = 0; n = 0;
for (i = 0; i < arity; ++i) { for (i = 0; i < arity; ++i) {
......
...@@ -565,7 +565,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) ...@@ -565,7 +565,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
/* we might need 1 birg more for instrumentation constructor */ /* we might need 1 birg more for instrumentation constructor */
num_birgs = backend_irg_list ? ARR_LEN(backend_irg_list) : get_irp_n_irgs(); num_birgs = backend_irg_list ? ARR_LEN(backend_irg_list) : get_irp_n_irgs();
birgs = alloca(sizeof(birgs[0]) * (num_birgs + 1)); birgs = ALLOCAN(be_irg_t, num_birgs + 1);
/* First: initialize all birgs */ /* First: initialize all birgs */
for(i = 0; i < num_birgs; ++i) { for(i = 0; i < num_birgs; ++i) {
...@@ -899,7 +899,7 @@ void be_main(FILE *file_handle, const char *cup_name) ...@@ -899,7 +899,7 @@ void be_main(FILE *file_handle, const char *cup_name)
if (be_options.statev) { if (be_options.statev) {
const char *dot = strrchr(cup_name, '.'); const char *dot = strrchr(cup_name, '.');
const char *pos = dot ? dot : cup_name + strlen(cup_name); const char *pos = dot ? dot : cup_name + strlen(cup_name);
char *buf = alloca(pos - cup_name + 1); char *buf = ALLOCAN(char, pos - cup_name + 1);
strncpy(buf, cup_name, pos - cup_name); strncpy(buf, cup_name, pos - cup_name);
buf[pos - cup_name] = '\0'; buf[pos - cup_name] = '\0';
......
...@@ -440,7 +440,7 @@ ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *b ...@@ -440,7 +440,7 @@ ir_node *be_new_Perm(const arch_register_class_t *cls, ir_graph *irg, ir_node *b
void be_Perm_reduce(ir_node *perm, int new_size, int *map) void be_Perm_reduce(ir_node *perm, int new_size, int *map)
{ {
int arity = get_irn_arity(perm); int arity = get_irn_arity(perm);
be_reg_data_t *old_data = alloca(arity * sizeof(old_data[0])); be_reg_data_t *old_data = ALLOCAN(be_reg_data_t, arity);
be_node_attr_t *attr = get_irn_attr(perm); be_node_attr_t *attr = get_irn_attr(perm);
ir_node **new_in; ir_node **new_in;
...@@ -474,7 +474,7 @@ ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl, ...@@ -474,7 +474,7 @@ ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_graph *irg, ir_node *bl,
ir_node **real_in; ir_node **real_in;
int i; int i;
real_in = alloca((n+1) * sizeof(real_in[0])); real_in = ALLOCAN(ir_node*, n + 1);
real_in[0] = frame; real_in[0] = frame;
memcpy(&real_in[1], in, n * sizeof(real_in[0])); memcpy(&real_in[1], in, n * sizeof(real_in[0]));
...@@ -790,8 +790,8 @@ ir_entity *be_get_FrameAddr_entity(const ir_node *node) ...@@ -790,8 +790,8 @@ ir_entity *be_get_FrameAddr_entity(const ir_node *node)
ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode) ir_node *be_new_CopyKeep(const arch_register_class_t *cls, ir_graph *irg, ir_node *bl, ir_node *src, int n, ir_node *in_keep[], ir_mode *mode)
{ {
ir_node *irn; ir_node *irn;
ir_node **in = (ir_node **) alloca((n + 1) * sizeof(in[0])); ir_node **in = ALLOCAN(ir_node*, n + 1);
in[0] = src; in[0] = src;
memcpy(&in[1], in_keep, n * sizeof(in[0])); memcpy(&in[1], in_keep, n * sizeof(in[0]));
......
...@@ -384,11 +384,11 @@ void be_peephole_opt(be_irg_t *birg) ...@@ -384,11 +384,11 @@ void be_peephole_opt(be_irg_t *birg)
lv = be_get_birg_liveness(birg); lv = be_get_birg_liveness(birg);
n_classes = arch_env_get_n_reg_class(arch_env); n_classes = arch_env_get_n_reg_class(arch_env);
register_values = alloca(sizeof(register_values[0]) * n_classes); register_values = ALLOCAN(ir_node**, n_classes);
for(i = 0; i < n_classes; ++i) { for(i = 0; i < n_classes; ++i) {
const arch_register_class_t *cls = arch_env_get_reg_class(arch_env, i); const arch_register_class_t *cls = arch_env_get_reg_class(arch_env, i);
unsigned n_regs = arch_register_class_n_regs(cls); unsigned n_regs = arch_register_class_n_regs(cls);
register_values[i] = alloca(sizeof(ir_node*) * n_regs); register_values[i] = ALLOCAN(ir_node*, n_regs);
} }
irg_block_walk_graph(irg, process_block, NULL, NULL); irg_block_walk_graph(irg, process_block, NULL, NULL);
......
...@@ -1347,7 +1347,7 @@ static void compute_dvg(rss_t *rss, dvg_t *dvg) { ...@@ -1347,7 +1347,7 @@ static void compute_dvg(rss_t *rss, dvg_t *dvg) {
static void update_dvg(rss_t *rss, dvg_t *dvg, rss_irn_t *src, rss_irn_t *tgt) { static void update_dvg(rss_t *rss, dvg_t *dvg, rss_irn_t *src, rss_irn_t *tgt) {
int i, j, idx; int i, j, idx;
rss_edge_t *edge; rss_edge_t *edge;
rss_edge_t **arr = alloca(pset_count(dvg->edges) * sizeof(arr[0])); rss_edge_t **arr = ALLOCAN(rss_edge_t*, pset_count(dvg->edges));
/* /*
Add an edge from serialization target to serialization src: Add an edge from serialization target to serialization src:
...@@ -1454,9 +1454,9 @@ static void build_dvg_pkiller_list(rss_t *rss, dvg_t *dvg) { ...@@ -1454,9 +1454,9 @@ static void build_dvg_pkiller_list(rss_t *rss, dvg_t *dvg) {
*/ */
static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int iteration) { static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int iteration) {
int n = ir_nodeset_size(&dvg->nodes); int n = ir_nodeset_size(&dvg->nodes);
int *assignment = alloca(n * sizeof(assignment[0])); int *assignment = ALLOCAN(int, n);
int *assignment_rev = alloca(n * sizeof(assignment_rev[0])); int *assignment_rev = ALLOCAN(int, n);
int *idx_map = alloca(n * sizeof(idx_map[0])); int *idx_map = ALLOCAN(int, n);
hungarian_problem_t *bp; hungarian_problem_t *bp;
ir_nodeset_t *values, *temp; ir_nodeset_t *values, *temp;
ir_nodeset_iterator_t iter; ir_nodeset_iterator_t iter;
...@@ -1718,7 +1718,7 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod ...@@ -1718,7 +1718,7 @@ static serialization_t *compute_best_admissible_serialization(rss_t *rss, ir_nod
int n = ir_nodeset_size(sat_vals); int n = ir_nodeset_size(sat_vals);
int n_idx = ARR_LEN_SAFE(rss->idx_map); int n_idx = ARR_LEN_SAFE(rss->idx_map);
int i = 0; int i = 0;
ir_node **val_arr = alloca(n * sizeof(val_arr[0])); ir_node **val_arr = ALLOCAN(ir_node*, n);
bitset_t *bs_sv = bitset_alloca(n_idx); bitset_t *bs_sv = bitset_alloca(n_idx);
bitset_t *bs_vdesc = bitset_alloca(n_idx); bitset_t *bs_vdesc = bitset_alloca(n_idx);
bitset_t *bs_tmp = bitset_alloca(n_idx); bitset_t *bs_tmp = bitset_alloca(n_idx);
......
...@@ -483,7 +483,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo) ...@@ -483,7 +483,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
/* build a new PhiM */ /* build a new PhiM */
arity = get_irn_arity(phi); arity = get_irn_arity(phi);
ins = alloca(sizeof(ir_node*) * arity); ins = ALLOCAN(ir_node*, arity);
unknown = new_r_Unknown(irg, mode_M); unknown = new_r_Unknown(irg, mode_M);
for(i = 0; i < arity; ++i) { for(i = 0; i < arity; ++i) {
ins[i] = unknown; ins[i] = unknown;
...@@ -689,7 +689,7 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader) ...@@ -689,7 +689,7 @@ static ir_node *do_remat(spill_env_t *env, ir_node *spilled, ir_node *reloader)
bl = get_nodes_block(reloader); bl = get_nodes_block(reloader);
} }
ins = alloca(get_irn_arity(spilled) * sizeof(ins[0])); ins = ALLOCAN(ir_node*, get_irn_arity(spilled));
for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) { for(i = 0, arity = get_irn_arity(spilled); i < arity; ++i) {
ir_node *arg = get_irn_n(spilled, i); ir_node *arg = get_irn_n(spilled, i);
......
...@@ -316,8 +316,8 @@ static inline unsigned get_distance(ir_node *from, unsigned from_step, ...@@ -316,8 +316,8 @@ static inline unsigned get_distance(ir_node *from, unsigned from_step,
*/ */
static void displace(workset_t *new_vals, int is_usage) static void displace(workset_t *new_vals, int is_usage)
{ {
ir_node **to_insert = alloca(n_regs * sizeof(to_insert[0])); ir_node **to_insert = ALLOCAN(ir_node*, n_regs);
bool *spilled = alloca(n_regs * sizeof(spilled[0])); bool *spilled = ALLOCAN(bool, n_regs);
ir_node *val; ir_node *val;
int i; int i;
int len; int len;
...@@ -551,7 +551,7 @@ static void decide_start_workset(const ir_node *block) ...@@ -551,7 +551,7 @@ static void decide_start_workset(const ir_node *block)
/* check predecessors */ /* check predecessors */
arity = get_irn_arity(block); arity = get_irn_arity(block);