Commit e07b61c6 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

Good day and welcome to the FIRM XMALLOC*() macros. These macros are provided...

Good day and welcome to the FIRM XMALLOC*() macros.  These macros are provided for the type safety and convenience of the IPD research facility personnel.  The time is 15:32.  Check xmalloc.h for details.

[r22494]
parent 325f4d96
......@@ -954,7 +954,7 @@ static void dump_initializer(be_gas_decl_env_t *env, ir_entity *entity)
* In the worst case, every initializer allocates one byte.
* Moreover, initializer might be big, do not allocate on stack.
*/
vals = xcalloc(size, sizeof(vals[0]));
vals = XMALLOCNZ(normal_or_bitfield, size);
#ifndef NDEBUG
glob_vals = vals;
......@@ -1043,7 +1043,7 @@ static void dump_compound_init(be_gas_decl_env_t *env, ir_entity *ent)
* In the worst case, every initializer allocates one byte.
* Moreover, initializer might be big, do not allocate on stack.
*/
vals = xcalloc(last_ofs, sizeof(vals[0]));
vals = XMALLOCNZ(normal_or_bitfield, last_ofs);
/* collect the values and store them at the offsets */
for (i = 0; i < n; ++i) {
......
......@@ -184,7 +184,7 @@ int be_ifg_is_simplicial(const be_ifg_t *ifg, const ir_node *irn)
int degree = be_ifg_degree(ifg, irn);
void *iter = be_ifg_neighbours_iter_alloca(ifg);
ir_node **neighbours = xmalloc(degree * sizeof(neighbours[0]));
ir_node **neighbours = XMALLOCN(ir_node*, degree);
ir_node *curr;
int i, j;
......@@ -276,7 +276,7 @@ void be_ifg_check_sorted(const be_ifg_t *ifg)
const int node_count = be_ifg_check_get_node_count(ifg);
int i = 0;
ir_node **all_nodes = xmalloc(node_count * sizeof(all_nodes[0]));
ir_node **all_nodes = XMALLOCN(ir_node*, node_count);
be_ifg_foreach_node(ifg, iter1, n)
{
......@@ -294,7 +294,7 @@ void be_ifg_check_sorted(const be_ifg_t *ifg)
for (i = 0; i < node_count; i++)
{
ir_node **neighbours = xmalloc(node_count * sizeof(neighbours[0]));
ir_node **neighbours = XMALLOCN(ir_node*, node_count);
int j = 0;
int k = 0;
int degree = 0;
......@@ -334,7 +334,7 @@ void be_ifg_check_sorted_to_file(const be_ifg_t *ifg, FILE *f)
const int node_count = be_ifg_check_get_node_count(ifg);
int i = 0;
ir_node **all_nodes = xmalloc(node_count * sizeof(all_nodes[0]));
ir_node **all_nodes = XMALLOCN(ir_node*, node_count);
be_ifg_foreach_node(ifg, iter1, n)
{
......@@ -352,7 +352,7 @@ void be_ifg_check_sorted_to_file(const be_ifg_t *ifg, FILE *f)
for (i = 0; i < node_count; i++)
{
ir_node **neighbours = xmalloc(node_count * sizeof(neighbours[0]));
ir_node **neighbours = XMALLOCN(ir_node*, node_count);
int j = 0;
int k = 0;
int degree = 0;
......
......@@ -539,7 +539,7 @@ static const be_ifg_impl_t ifg_clique_impl = {
be_ifg_t *be_ifg_clique_new(const be_chordal_env_t *env)
{
ifg_clique_t *ifg = xmalloc(sizeof(*ifg));
ifg_clique_t *ifg = XMALLOC(ifg_clique_t);
ifg->impl = &ifg_clique_impl;
ifg->env = env;
......
......@@ -427,13 +427,12 @@ static const be_ifg_impl_t ifg_list_impl = {
be_ifg_t *be_ifg_list_new(const be_chordal_env_t *env)
{
ifg_list_t *ifg = xmalloc(sizeof(*ifg));
adj_head_t **adj_heads_array = xmalloc(env->irg->last_node_idx * sizeof(adj_heads_array[0]));
ifg_list_t *ifg = XMALLOC(ifg_list_t);
adj_head_t **adj_heads_array = XMALLOCNZ(adj_head_t*, env->irg->last_node_idx);
ifg->impl = &ifg_list_impl;
ifg->env = env;
memset(adj_heads_array, 0, env->irg->last_node_idx * sizeof(adj_heads_array[0]));
ifg->adj_heads = adj_heads_array;
obstack_init(&ifg->obst);
......
......@@ -670,7 +670,7 @@ static const be_ifg_impl_t ifg_pointer_impl = {
be_ifg_t *be_ifg_pointer_new(const be_chordal_env_t *env)
{
ifg_pointer_t *ifg = xmalloc(sizeof(*ifg));
ifg_pointer_t *ifg = XMALLOC(ifg_pointer_t);
ifg->impl = &ifg_pointer_impl;
ifg->env = env;
......
......@@ -372,7 +372,7 @@ static const be_ifg_impl_t ifg_std_impl = {
be_ifg_t *be_ifg_std_new(const be_chordal_env_t *env)
{
ifg_std_t *ifg = xmalloc(sizeof(*ifg));
ifg_std_t *ifg = XMALLOC(ifg_std_t);
ifg->impl = &ifg_std_impl;
ifg->env = env;
......
......@@ -106,7 +106,7 @@ ir_node *insert_Perm_after(be_irg_t *birg,
return NULL;
}
nodes = xmalloc(n * sizeof(nodes[0]));
nodes = XMALLOCN(ir_node*, n);
DBG((dbg, LEVEL_1, "live:\n"));
i = 0;
......
......@@ -153,7 +153,7 @@ static int start_vm(jni_env_t *env, int argc, char *argv[])
}
memset(&args, 0, sizeof(args));
opts = xmalloc(argc * sizeof(opts[0]));
opts = XMALLOCN(JavaVMOption, argc);
for(i = 0; i < argc; ++i) {
opts[i].optionString = argv[i];
opts[i].extraInfo = NULL;
......@@ -326,7 +326,6 @@ static int jc_call_int(be_java_coal_t *c, int mth_index, ...)
be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_regs, int dbg_level)
{
be_java_coal_t *c;
jni_env_t *env = get_jvm();
JNIEnv *jni = env->jni;
jmethodID fact;
......@@ -334,8 +333,7 @@ be_java_coal_t *be_java_coal_init(const char *graph_name, int n_nodes, int n_reg
jstring str;
int i;
c = xmalloc(sizeof(c[0]));
memset(c, 0, sizeof(c[0]));
be_java_coal_t *c = XMALLOCZ(be_java_coal_t);
c->env = env;
/* Find the class we are are looking for. */
......
......@@ -585,9 +585,8 @@ void be_liveness_invalidate(be_lv_t *lv)
/* Compute the inter block liveness for a graph. */
be_lv_t *be_liveness(const be_irg_t *birg)
{
be_lv_t *lv = xmalloc(sizeof(lv[0]));
be_lv_t *lv = XMALLOCZ(be_lv_t);
memset(lv, 0, sizeof(lv[0]));
lv->irg = be_get_birg_irg(birg);
lv->birg = birg;
#ifdef USE_LIVE_CHK
......
......@@ -162,7 +162,7 @@ static unsigned be_compute_loop_pressure(be_loopana_t *loop_ana, ir_loop *loop,
be_loopana_t *be_new_loop_pressure_cls(be_irg_t *birg,
const arch_register_class_t *cls) {
ir_graph *irg = be_get_birg_irg(birg);
be_loopana_t *loop_ana = xmalloc(sizeof(*loop_ana));
be_loopana_t *loop_ana = XMALLOC(be_loopana_t);
loop_ana->data = new_set(cmp_loop_info, 16);
loop_ana->birg = birg;
......@@ -190,7 +190,7 @@ be_loopana_t *be_new_loop_pressure(be_irg_t *birg,
const arch_register_class_t *cls)
{
ir_graph *irg = be_get_birg_irg(birg);
be_loopana_t *loop_ana = xmalloc(sizeof(*loop_ana));
be_loopana_t *loop_ana = XMALLOC(be_loopana_t);
ir_loop *irg_loop = get_irg_loop(irg);
const arch_env_t *arch_env = be_get_birg_arch_env(birg);
int i;
......
......@@ -225,7 +225,7 @@ static perm_cycle_t *get_perm_cycle(perm_cycle_t *cycle, reg_pair_t *pairs, int
}
/* assume worst case: all remaining pairs build a cycle or chain */
cycle->elems = xcalloc((n - n_pairs_done) * 2, sizeof(cycle->elems[0]));
cycle->elems = XMALLOCNZ(const arch_register_t*, (n - n_pairs_done) * 2);
cycle->n_elems = 2; /* initial number of elements is 2 */
cycle->elems[0] = pairs[start].in_reg;
cycle->elems[1] = pairs[start].out_reg;
......@@ -290,7 +290,6 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
int n, i, pn, do_copy, j, n_ops;
reg_pair_t *pairs;
const ir_edge_t *edge;
perm_cycle_t *cycle;
ir_node *sched_point, *block, *in[2];
ir_node *arg1, *arg2, *res1, *res2;
ir_node *cpyxchg = NULL;
......@@ -367,11 +366,13 @@ static void lower_perm_node(ir_node *irn, void *walk_env) {
/* check for cycles and chains */
while (get_n_checked_pairs(pairs, n) < n) {
perm_cycle_t *cycle;
i = n_ops = 0;
/* go to the first not-checked pair */
while (pairs[i].checked) i++;
cycle = xcalloc(1, sizeof(*cycle));
cycle = XMALLOCZ(perm_cycle_t);
cycle = get_perm_cycle(cycle, pairs, n, i);
DB((mod, LEVEL_1, "%+F: following %s created:\n ", irn, cycle->type == PERM_CHAIN ? "chain" : "cycle"));
......
......@@ -250,9 +250,7 @@ int dump_opt_module_vals(char *buf, size_t buflen, const char *name,
void be_add_module_to_list(be_module_list_entry_t **list_head, const char *name,
void *module)
{
be_module_list_entry_t *entry;
entry = xmalloc(sizeof(entry[0]));
be_module_list_entry_t *entry = XMALLOC(be_module_list_entry_t);
entry->name = name;
entry->data = module;
entry->next = *list_head;
......@@ -267,9 +265,7 @@ void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
be_module_list_entry_t * const * list_head,
void **var)
{
module_opt_data_t *moddata;
moddata = xmalloc(sizeof(moddata[0]));
module_opt_data_t *moddata = XMALLOC(module_opt_data_t);
moddata->var = var;
moddata->list_head = list_head;
......
......@@ -513,7 +513,7 @@ void dump_ir_block_graph_mris(mris_env_t *env, const char *suffix) {
mris_env_t *be_sched_mris_preprocess(const be_irg_t *birg)
{
mris_env_t *env = xmalloc(sizeof(env[0]));
mris_env_t *env = XMALLOC(mris_env_t);
ir_graph *irg = be_get_birg_irg(birg);
phase_init(&env->ph, "mris", irg, 2 * PHASE_DEFAULT_GROWTH, mris_irn_data_init, NULL);
......
......@@ -176,7 +176,7 @@ static int compute_max_hops(reg_pressure_selector_env_t *env, ir_node *irn)
static void *reg_pressure_graph_init(const list_sched_selector_t *vtab, const be_irg_t *birg)
{
reg_pressure_main_env_t *main_env = xmalloc(sizeof(main_env[0]));
reg_pressure_main_env_t *main_env = XMALLOC(reg_pressure_main_env_t);
main_env->arch_env = be_get_birg_arch_env(birg);
main_env->vtab = vtab;
......@@ -198,7 +198,7 @@ static INLINE int must_appear_in_schedule(const list_sched_selector_t *sel, void
static void *reg_pressure_block_init(void *graph_env, ir_node *bl)
{
ir_node *irn;
reg_pressure_selector_env_t *env = xmalloc(sizeof(env[0]));
reg_pressure_selector_env_t *env = XMALLOC(reg_pressure_selector_env_t);
obstack_init(&env->obst);
ir_nodeset_init(&env->already_scheduled);
......
......@@ -1568,7 +1568,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
DBG((rss->dbg, LEVEL_3, "\t\t\t%3d -> %3d %3d -> %3d\n", i, assignment[i], i, assignment_rev[i]));
}
values = xmalloc(sizeof(values[0]));
values = XMALLOC(ir_nodeset_t);
ir_nodeset_init_size(values, 10);
cur_chain = 0;
/* Construction of the minimal chain partition */
......@@ -1646,7 +1646,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
free(temp);
}
temp = xmalloc(sizeof(temp[0]));
temp = XMALLOC(ir_nodeset_t);
ir_nodeset_init_size(temp, 10);
/* Select all nodes from current value set, having another node in the set as descendant. */
......
......@@ -496,7 +496,7 @@ static void trace_update_time(void *data, ir_node *irn) {
* @return The environment
*/
static trace_env_t *trace_init(const be_irg_t *birg) {
trace_env_t *env = xcalloc(1, sizeof(*env));
trace_env_t *env = XMALLOCZ(trace_env_t);
ir_graph *irg = be_get_birg_irg(birg);
int nn = get_irg_last_idx(irg);
......
......@@ -155,7 +155,7 @@ spill_env_t *be_new_spill_env(be_irg_t *birg)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
spill_env_t *env = xmalloc(sizeof(env[0]));
spill_env_t *env = XMALLOC(spill_env_t);
env->spills = new_set(cmp_spillinfo, 1024);
env->irg = be_get_birg_irg(birg);
env->birg = birg;
......
......@@ -41,7 +41,6 @@
#include "ircons_t.h"
#include "irprintf.h"
#include "irnodeset.h"
#include "xmalloc.h"
#include "beutil.h"
#include "bearch_t.h"
......
......@@ -54,7 +54,6 @@
#include "irprintf.h"
#include "execfreq.h"
#include "dfs_t.h"
#include "xmalloc.h"
#include "beutil.h"
#include "bearch_t.h"
......
......@@ -767,7 +767,7 @@ static int count_spillslots(const be_fec_env_t *env)
be_fec_env_t *be_new_frame_entity_coalescer(be_irg_t *birg)
{
const arch_env_t *arch_env = birg->main_env->arch_env;
be_fec_env_t *env = xmalloc(sizeof(env[0]));
be_fec_env_t *env = XMALLOC(be_fec_env_t);
be_liveness_assure_chk(be_assure_liveness(birg));
......
Markdown is supported
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