Add OALLOC*() to make allocating from obstacks a bit nicer.
authorChristoph Mallon <christoph.mallon@gmx.de>
Wed, 2 Sep 2009 10:40:20 +0000 (10:40 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Wed, 2 Sep 2009 10:40:20 +0000 (10:40 +0000)
[r26468]

60 files changed:
include/libfirm/adt/xmalloc.h
ir/adt/hungarian.c
ir/adt/plist.c
ir/adt/set.c
ir/ana/callgraph.c
ir/ana/cdep.c
ir/ana/ircfscc.c
ir/ana/irextbb.c
ir/ana/irextbb2.c
ir/ana/irlivechk.c
ir/ana/irloop.c
ir/ana/irscc.c
ir/ana/structure.c
ir/be/beabi.c
ir/be/beblocksched.c
ir/be/bechordal.c
ir/be/bechordal_draw.c
ir/be/becopyheur2.c
ir/be/becopyilp.c
ir/be/becopyopt.c
ir/be/beifg_clique.c
ir/be/beifg_list.c
ir/be/beifg_pointer.c
ir/be/beilpsched.c
ir/be/beinfo.c
ir/be/beinsn.c
ir/be/belower.c
ir/be/benewalloc.c
ir/be/benode.c
ir/be/beschednormal.c
ir/be/beschedregpress.c
ir/be/beschedrss.c
ir/be/bespillbelady.c
ir/be/bespillbelady2.c
ir/be/bespillbelady3.c
ir/be/bespillslots.c
ir/be/bespillutil.c
ir/be/bestate.c
ir/common/debug.c
ir/ir/irarch.c
ir/ir/irdump_grgen.c
ir/ir/irgwalk_blk.c
ir/libcore/lc_opts.c
ir/lower/lower_calls.c
ir/lower/lower_copyb.c
ir/lower/lower_dw.c
ir/opt/combo.c
ir/opt/escape_ana.c
ir/opt/gvn_pre.c
ir/opt/ldstopt.c
ir/opt/opt_blocks.c
ir/opt/opt_inline.c
ir/opt/opt_ldst.c
ir/opt/opt_osr.c
ir/opt/proc_cloning.c
ir/stat/dags.c
ir/stat/distrib.c
ir/stat/firmstat.c
ir/stat/pattern.c
ir/stat/stat_liveness.c

index d9d8d75..f378ff0 100644 (file)
@@ -71,13 +71,13 @@ char *xstrdup(const char *str);
 /**
  * Allocate an object with n elements of a flexible array member
  */
-#define XMALLOCF(type, member, n) ((type*)xmalloc(offsetof(type, member) + sizeof(((type*)0)->member) * (n)))
+#define XMALLOCF(type, member, n) ((type*)xmalloc(offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
 
 /**
  * Allocate an object with n elements of a flexible array member and zero the
  * whole object
  */
-#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(XMALLOCF(type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
 
 /**
  * Allocate n objects of a certain type on the stack
@@ -89,6 +89,38 @@ char *xstrdup(const char *str);
  */
 #define ALLOCANZ(type, n) ((type*)memset((type*)alloca(sizeof(type) * (n)), 0, sizeof(type) * (n)))
 
+/**
+ * Allocate n objects of a certain type on the given obstack
+ */
+#define OALLOCN(obst, type, n) ((type*)obstack_alloc((obst), sizeof(type) * (n)))
+
+/**
+ * Allocate n objects of a certain type on the given obstack and zero them
+ */
+#define OALLOCNZ(obst, type, n) ((type*)memset(OALLOCN((obst), type, (n)), 0, sizeof(type) * (n)))
+
+/**
+ * Allocate one object of a certain type on the given obstack
+ */
+#define OALLOC(obst, type) OALLOCN(obst, type, 1)
+
+/**
+ * Allocate one object of a certain type on the given obstack and zero it
+ */
+#define OALLOCZ(obst, type) OALLOCNZ(obst, type, 1)
+
+/**
+ * Allocate an object with n elements of a flexible array member on the given
+ * obstck
+ */
+#define OALLOCF(obst, type, member, n) ((type*)obstack_alloc((obst), offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
+
+/**
+ * Allocate an object with n elements of a flexible array member on the given
+ * obstack and zero the whole object
+ */
+#define OALLOCFZ(obst, type, member, n) ((type*)memset(OALLOCF((obst), type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n)))
+
 
 /* Includes for alloca() */
 #ifdef _WIN32
index c38cb47..0b3134a 100644 (file)
@@ -57,12 +57,6 @@ struct _hungarian_problem_t {
        DEBUG_ONLY(firm_dbg_module_t *dbg);
 };
 
-static inline void *get_init_mem(struct obstack *obst, size_t sz) {
-       void *p = obstack_alloc(obst, sz);
-       memset(p, 0, sz);
-       return p;
-}
-
 static void hungarian_dump_f(FILE *f, int **C, int rows, int cols, int width) {
        int i, j;
 
@@ -116,9 +110,9 @@ hungarian_problem_t *hungarian_new(int rows, int cols, int match_type) {
        }
 
        /* allocate space for cost matrix */
-       p->cost = (int **)get_init_mem(&p->obst, rows * sizeof(p->cost[0]));
+       p->cost = OALLOCNZ(&p->obst, int*, rows);
        for (i = 0; i < p->num_rows; i++)
-               p->cost[i] = (int *)get_init_mem(&p->obst, cols * sizeof(p->cost[0][0]));
+               p->cost[i] = OALLOCNZ(&p->obst, int, cols);
 
        return p;
 }
index aea85f5..99711e1 100644 (file)
@@ -48,7 +48,7 @@ static plist_element_t *allocate_element(plist_t* list) {
                new_element->next        = NULL;
        }
        else {
-               new_element = obstack_alloc(list->obst, sizeof(*new_element));
+               new_element = OALLOC(list->obst, plist_element_t);
        }
 
        return new_element;
@@ -69,7 +69,7 @@ plist_t *plist_new(void) {
 }
 
 plist_t *plist_obstack_new(struct obstack *obst) {
-       plist_t *list = obstack_alloc(obst, sizeof(*list));
+       plist_t *list = OALLOC(obst, plist_t);
 
        list->obst               = obst;
        list->foreign_obstack    = 1;
index eceee45..0db15e7 100644 (file)
@@ -206,10 +206,7 @@ SET *
 
   /* Make segments */
   for (i = 0;  i < nslots;  ++i) {
-    table->dir[i] = (Segment *)obstack_alloc (&table->obst,
-                                             sizeof (Segment) * SEGMENT_SIZE);
-
-    memset(table->dir[i], 0, sizeof (Segment) * SEGMENT_SIZE);
+    table->dir[i] = OALLOCNZ(&table->obst, Segment, SEGMENT_SIZE);
     table->nseg++;
   }
 
@@ -357,10 +354,7 @@ expand_table (SET *table)
     NewSegmentDir   = NewAddress >> SEGMENT_SIZE_SHIFT;
     NewSegmentIndex = NewAddress & (SEGMENT_SIZE-1);
     if (NewSegmentIndex == 0) {
-      table->dir[NewSegmentDir] =
-       (Segment *)obstack_alloc (&table->obst,
-                                 sizeof(Segment) * SEGMENT_SIZE);
-      memset(table->dir[NewSegmentDir], 0, sizeof(Segment) * SEGMENT_SIZE);
+      table->dir[NewSegmentDir] = OALLOCNZ(&table->obst, Segment, SEGMENT_SIZE);
       table->nseg++;
     }
     NewSegment = table->dir[NewSegmentDir];
@@ -443,7 +437,7 @@ MANGLE(_,_search) (SET *table,
       q = table->free_list;
       table->free_list = table->free_list->chain;
     } else {
-      q = obstack_alloc (&table->obst, sizeof (Element));
+      q = OALLOC(&table->obst, Element);
     }
     q->entry.dptr = (void *)key;
 #else
index c21e32c..b99c6fb 100644 (file)
@@ -249,7 +249,7 @@ static void ana_Call(ir_node *n, void *env) {
                                ARR_APP1(ir_node *, arr, n);
                                found->call_list = arr;
                        } else { /* New node, add Call node and init nesting. */
-                               found = (cg_callee_entry *)obstack_alloc(irg->obst, sizeof(*found));
+                               found = OALLOC(irg->obst, cg_callee_entry);
                                found->irg = callee;
                                found->call_list = NEW_ARR_F(ir_node *, 1);
                                found->call_list[0] = n;
@@ -428,9 +428,7 @@ typedef struct scc_info {
  * allocates a new scc_info on the obstack
  */
 static inline scc_info *new_scc_info(struct obstack *obst) {
-       scc_info *info = obstack_alloc(obst, sizeof(*info));
-       memset(info, 0, sizeof(*info));
-       return info;
+       return OALLOCZ(obst, scc_info);
 }
 
 /**
index 49eeec0..5a2057f 100644 (file)
@@ -64,7 +64,7 @@ static void add_cdep(ir_node *node, ir_node *dep_on) {
 #endif
 
        if (dep == NULL) {
-               ir_cdep *newdep = obstack_alloc(&cdep_data->obst, sizeof(*newdep));
+               ir_cdep *newdep = OALLOC(&cdep_data->obst, ir_cdep);
 
                newdep->node = dep_on;
                newdep->next = NULL;
@@ -77,7 +77,7 @@ static void add_cdep(ir_node *node, ir_node *dep_on) {
                        if (dep->next == NULL) break;
                        dep = dep->next;
                }
-               newdep = obstack_alloc(&cdep_data->obst, sizeof(*newdep));
+               newdep = OALLOC(&cdep_data->obst, ir_cdep);
                newdep->node = dep_on;
                newdep->next = NULL;
                dep->next = newdep;
index c069ed0..25f9731 100644 (file)
@@ -77,9 +77,7 @@ typedef struct scc_info {
 
 /** Allocate a new scc_info on the given obstack */
 static inline scc_info *new_scc_info(struct obstack *obst) {
-       scc_info *info = obstack_alloc(obst, sizeof(*info));
-       memset(info, 0, sizeof(*info));
-       return info;
+       return OALLOCZ(obst, scc_info);
 }
 
 /**
index ebc5551..6fee71f 100644 (file)
@@ -52,7 +52,7 @@ int (is_ir_extbb)(const void *thing) {
  * allocate a new extended block header.
  */
 static void allocate_extblk(ir_node *block, env_t *env) {
-       ir_extblk *extblk = obstack_alloc(env->obst, sizeof(*extblk));
+       ir_extblk *extblk = OALLOC(env->obst, ir_extblk);
 
        extblk->kind    = k_ir_extblk;
        extblk->visited = 1;
index 726dbb6..602e393 100644 (file)
@@ -50,7 +50,7 @@ typedef struct _env {
  */
 static ir_extblk *allocate_extblk(ir_node *block, env_t *env)
 {
-       ir_extblk *extblk = obstack_alloc(env->obst, sizeof(*extblk));
+       ir_extblk *extblk = OALLOC(env->obst, ir_extblk);
 
        extblk->kind    = k_ir_extblk;
        extblk->visited = 1;
index 36d0fce..362eb28 100644 (file)
@@ -260,8 +260,7 @@ lv_chk_t *lv_chk_new(ir_graph *irg, const dfs_t *dfs)
        res->n_blocks      = dfs_get_n_nodes(res->dfs);
        res->back_edge_src = bitset_obstack_alloc(obst, res->n_blocks);
        res->back_edge_tgt = bitset_obstack_alloc(obst, res->n_blocks);
-       res->map           = obstack_alloc(obst, res->n_blocks * sizeof(res->map[0]));
-       memset(res->map, 0, res->n_blocks * sizeof(res->map[0]));
+       res->map           = OALLOCNZ(obst, bl_info_t*, res->n_blocks);
 
 #if 0
        {
index 2f167af..1722d48 100644 (file)
@@ -220,8 +220,7 @@ ir_loop *(get_irg_loop)(const ir_graph *irg) {
 ir_loop *alloc_loop(ir_loop *father, struct obstack *obst) {
        ir_loop *son;
 
-       son = obstack_alloc(obst, sizeof(*son));
-       memset(son, 0, sizeof(*son));
+       son = OALLOCZ(obst, ir_loop);
        son->kind     = k_ir_loop;
        son->children = NEW_ARR_F(loop_element, 0);
        son->n_nodes  = 0;
index bea7231..8205a1b 100644 (file)
@@ -88,9 +88,7 @@ typedef struct scc_info {
  * Allocates a new SCC info on the given obstack.
  */
 static inline scc_info *new_scc_info(struct obstack *obst) {
-       scc_info *info = obstack_alloc(obst, sizeof(*info));
-       memset(info, 0, sizeof(*info));
-       return info;
+       return OALLOCZ(obst, scc_info);
 }
 
 /**
index 06ab7d3..356225f 100644 (file)
@@ -228,7 +228,7 @@ static void wrap_BasicBlocks(ir_node *block, void *ctx) {
        ir_region *reg;
 
        /* Allocate a Block wrapper */
-       reg          = obstack_alloc(env->obst, sizeof(*reg));
+       reg          = OALLOC(env->obst, ir_region);
        reg->kind    = k_ir_region;
        reg->type    = ir_rk_BasicBlock;
        reg->parent  = NULL;
@@ -281,7 +281,7 @@ static void update_BasicBlock_regions(ir_node *blk, void *ctx) {
 /** Allocate a new region on an obstack */
 #define ALLOC_REG(obst, reg, tp) \
        do { \
-               (reg)          = obstack_alloc((obst), sizeof(*(reg))); \
+               (reg)          = OALLOC((obst), ir_region); \
                (reg)->kind    = k_ir_region; \
                (reg)->type    = tp; \
                (reg)->parent  = NULL; \
index 2f6b980..086c3a0 100644 (file)
@@ -1260,7 +1260,7 @@ static ir_type *compute_arg_type(be_abi_irg_t *env, be_abi_call_t *call,
        ident *id = get_entity_ident(get_irg_entity(env->birg->irg));
        ir_entity **map;
 
-       *param_map = map = obstack_alloc(&env->obst, n * sizeof(ir_entity *));
+       *param_map = map = OALLOCN(&env->obst, ir_entity*, n);
        res = new_type_struct(id_mangle_u(id, new_id_from_chars("arg_type", 8)));
        for (i = 0; i < n; ++i, curr += inc) {
                ir_type *param_type    = get_method_param_type(method_type, curr);
@@ -1315,7 +1315,7 @@ static reg_node_map_t *reg_map_to_arr(struct obstack *obst, pmap *reg_map)
        pmap_entry *ent;
        int n = pmap_count(reg_map);
        int i = 0;
-       reg_node_map_t *res = obstack_alloc(obst, n * sizeof(res[0]));
+       reg_node_map_t *res = OALLOCN(obst, reg_node_map_t, n);
 
        foreach_pmap(reg_map, ent) {
                res[i].reg = ent->key;
@@ -1410,7 +1410,7 @@ static ir_node *create_be_return(be_abi_irg_t *env, ir_node *irn, ir_node *bl,
        ir_node **in;
        ir_node *stack;
        const arch_register_t **regs;
-       pmap_entry *ent ;
+       pmap_entry *ent;
 
        /*
                get the valid stack node in this block.
@@ -1453,8 +1453,8 @@ static ir_node *create_be_return(be_abi_irg_t *env, ir_node *irn, ir_node *bl,
        */
        in_max = pmap_count(reg_map) + n_res + 2;
 
-       in   = obstack_alloc(&env->obst, in_max * sizeof(in[0]));
-       regs = obstack_alloc(&env->obst, in_max * sizeof(regs[0]));
+       in   = OALLOCN(&env->obst, ir_node*,               in_max);
+       regs = OALLOCN(&env->obst, arch_register_t const*, in_max);
 
        in[0]   = mem;
        in[1]   = be_abi_reg_map_get(reg_map, arch_env->sp);
@@ -1892,8 +1892,7 @@ static void modify_irg(be_abi_irg_t *env)
        env->regs  = pmap_create();
 
        n_params = get_method_n_params(method_type);
-       args     = obstack_alloc(&env->obst, n_params * sizeof(args[0]));
-       memset(args, 0, n_params * sizeof(args[0]));
+       args     = OALLOCNZ(&env->obst, ir_node*, n_params);
 
        /*
         * for inner function we must now fix access to outer frame entities.
@@ -2314,8 +2313,7 @@ be_abi_irg_t *be_abi_introduce(be_irg_t *birg)
        env->dce_survivor = new_survive_dce();
        env->birg         = birg;
 
-       sp_req = obstack_alloc(&env->obst, sizeof(*sp_req));
-       memset(sp_req, 0, sizeof(*sp_req));
+       sp_req = OALLOCZ(&env->obst, arch_register_req_t);
        env->sp_req = sp_req;
 
        sp_req->type = arch_register_req_type_limited
index b8de83b..412b9e4 100644 (file)
@@ -145,8 +145,7 @@ static void collect_egde_frequency(ir_node *block, void *data)
 
        memset(&edge, 0, sizeof(edge));
 
-       entry = obstack_alloc(env->obst, sizeof(entry[0]));
-       memset(entry, 0, sizeof(*entry));
+       entry = OALLOCZ(env->obst, blocksched_entry_t);
        entry->block = block;
        set_irn_link(block, entry);
 
@@ -585,7 +584,7 @@ static void collect_egde_frequency_ilp(ir_node *block, void *data)
        snprintf(name, sizeof(name), "block_out_constr_%ld", get_irn_node_nr(block));
        out_count = get_irn_n_edges_kind(block, EDGE_KIND_BLOCK);
 
-       entry          = obstack_alloc(env->env.obst, sizeof(entry[0]));
+       entry          = OALLOC(env->env.obst, blocksched_ilp_entry_t);
        entry->block   = block;
        entry->next    = NULL;
        entry->prev    = NULL;
index 7c3bafa..26ce6b6 100644 (file)
@@ -127,11 +127,10 @@ static inline border_t *border_add(be_chordal_env_t *env, struct list_head *head
        if (!is_def) {
                border_t *def;
 
-               b = obstack_alloc(env->obst, sizeof(*b));
+               b = OALLOC(env->obst, border_t);
 
                /* also allocate the def and tie it to the use. */
-               def = obstack_alloc(env->obst, sizeof(*def));
-               memset(def, 0, sizeof(*def));
+               def = OALLOCZ(env->obst, border_t);
                b->other_end = def;
                def->other_end = b;
 
@@ -630,7 +629,7 @@ static void pressure(ir_node *block, void *env_ptr)
        bitset_clear_all(live);
 
        /* Set up the border list in the block info */
-       head = obstack_alloc(env->obst, sizeof(*head));
+       head = OALLOC(env->obst, struct list_head);
        INIT_LIST_HEAD(head);
        assert(pmap_get(env->border_heads, block) == NULL);
        pmap_insert(env->border_heads, block, head);
index f349a76..547319f 100644 (file)
@@ -263,10 +263,9 @@ static void block_dims_walker(ir_node *block, void *data)
        draw_chordal_env_t        *env  = data;
        struct list_head          *head = get_block_border_head(env->chordal_env, block);
        const draw_chordal_opts_t *opts = env->opts;
-       struct block_dims         *dims = obstack_alloc(&env->obst, sizeof(*dims));
+       struct block_dims         *dims = OALLOCZ(&env->obst, struct block_dims);
        border_t                  *b;
 
-       memset(dims, 0, sizeof(*dims));
        dims->min_step = INT_MAX;
 
        list_for_each_entry_reverse(border_t, b, head, list) {
index 801f673..5b163cd 100644 (file)
@@ -986,18 +986,13 @@ static void process_cloud(co2_cloud_t *cloud)
                int n_childs = ci->mst_n_childs;
                int j;
 
-               ci->col_costs       = obstack_alloc(&cloud->obst, n_regs * sizeof(ci->col_costs[0]));
-               ci->tmp_coloring    = obstack_alloc(&cloud->obst, n_regs * sizeof(ci->tmp_coloring[0]));
-               ci->fronts          = obstack_alloc(&cloud->obst, n_regs * n_childs * sizeof(ci->fronts[0]));
-               ci->color_badness   = obstack_alloc(&cloud->obst, n_regs * sizeof(ci->fronts[0]));
-               memset(ci->color_badness, 0, n_regs * sizeof(ci->color_badness[0]));
-               memset(ci->col_costs,     0, n_regs * sizeof(ci->col_costs[0]));
-               memset(ci->tmp_coloring,  0, n_regs * sizeof(ci->tmp_coloring[0]));
-               memset(ci->fronts,        0, n_regs * n_childs * sizeof(ci->fronts[0]));
+               ci->col_costs       = OALLOCNZ(&cloud->obst, int,             n_regs);
+               ci->tmp_coloring    = OALLOCNZ(&cloud->obst, col_cost_pair_t, n_regs);
+               ci->fronts          = OALLOCNZ(&cloud->obst, int,             n_regs * n_childs);
+               ci->color_badness   = OALLOCNZ(&cloud->obst, int,             n_regs);
 
                for(j = 0; j < env->n_regs; j++)
                        ci->col_costs[j] = INT_MAX;
-
        }
 
        determine_color_badness(cloud->mst_root, 0);
index 3a9446a..dd79748 100644 (file)
@@ -144,7 +144,7 @@ void sr_remove(size_red_t *sr) {
 
                        if (!arch_register_req_is(req, limited) && !sr_is_removed(sr, irn) && !co_gs_is_optimizable(sr->co, irn)) {
                                if (sr_is_simplicial(sr, irn)) {
-                                       coloring_suffix_t *cs = obstack_alloc(&sr->ob, sizeof(*cs));
+                                       coloring_suffix_t *cs = OALLOC(&sr->ob, coloring_suffix_t);
 
                                        cs->irn = irn;
                                        cs->next = sr->col_suff;
index d503921..24fbefd 100644 (file)
@@ -752,7 +752,7 @@ static void add_edge(copy_opt_t *co, ir_node *n1, ir_node *n2, int costs) {
 
        /* if we did not find n2 in n1's neighbourhood insert it */
        if (allocnew) {
-               nbr        = obstack_alloc(&co->obst, sizeof(*nbr));
+               nbr        = OALLOC(&co->obst, neighb_t);
                nbr->irn   = n2;
                nbr->costs = 0;
                nbr->next  = node->neighbours;
index 4fe6412..c8864f8 100644 (file)
@@ -79,7 +79,7 @@ static cli_head_t *get_new_cli_head(ifg_clique_t *ifg)
 
        if (ifg->cli_root == NULL)
        {
-               new_cli_head = obstack_alloc(&ifg->obst, sizeof(*new_cli_head));
+               new_cli_head = OALLOC(&ifg->obst, cli_head_t);
                INIT_LIST_HEAD(&new_cli_head->list);
                ifg->cli_root = new_cli_head;
        }
@@ -90,7 +90,7 @@ static cli_head_t *get_new_cli_head(ifg_clique_t *ifg)
                {
                        cli_head = cli_head->next_cli_head;
                }
-               new_cli_head = obstack_alloc(&ifg->obst, sizeof(*new_cli_head));
+               new_cli_head = OALLOC(&ifg->obst, cli_head_t);
                INIT_LIST_HEAD(&new_cli_head->list);
                cli_head->next_cli_head = new_cli_head;
        }
@@ -107,7 +107,7 @@ static cli_element_t *get_new_cli_element(ifg_clique_t *ifg)
 {
        cli_element_t *cli_element;
 
-       cli_element = obstack_alloc(&ifg->obst, sizeof(*cli_element));
+       cli_element = OALLOC(&ifg->obst, cli_element_t);
        INIT_LIST_HEAD(&cli_element->list);
 
        return cli_element;
index fb81c27..117815e 100644 (file)
@@ -83,7 +83,7 @@ static void create_node(ifg_list_t *ifg, ir_node *irn)
        adj_head = ifg->adj_heads[irn->node_idx];
        if (!adj_head)
        {
-               adj_head = obstack_alloc(&ifg->obst, sizeof(*adj_head));
+               adj_head = OALLOC(&ifg->obst, adj_head_t);
                adj_head->irn = irn;
                adj_head->first_adj_element = NULL;
                adj_head->degree = 0;
@@ -95,7 +95,7 @@ static adj_element_t *create_adj_element(ifg_list_t *ifg, ir_node *irn)
 {
        adj_element_t *element = NULL;
 
-       element = obstack_alloc(&ifg->obst, sizeof(*element));
+       element = OALLOC(&ifg->obst, adj_element_t);
        element->next_adj_element = NULL;
        element->neighbour = irn;
 
index 5dfc09f..9d39d3c 100644 (file)
@@ -94,14 +94,13 @@ static void *ptr_irn_data_init(ir_phase *ph, const ir_node *irn, void *data)
 
 static ptr_element_t *ptr_get_new_element(ifg_pointer_t *ifg)
 {
-       ptr_element_t *new_element = obstack_alloc(&ifg->obst, sizeof(ptr_element_t));
-       memset(new_element, 0, sizeof(*new_element));
+       ptr_element_t *new_element = OALLOCZ(&ifg->obst, ptr_element_t);
        return new_element;
 }
 
 static ptr_head_t *ptr_get_new_head(ifg_pointer_t *ifg)
 {
-       ptr_head_t *new_element = obstack_alloc(&ifg->obst, sizeof(*new_element));
+       ptr_head_t *new_element = OALLOC(&ifg->obst, ptr_head_t);
        INIT_LIST_HEAD(&new_element->list);
        return new_element;
 }
index 105e139..8e7c76e 100644 (file)
@@ -1058,7 +1058,7 @@ static void create_variables(be_ilpsched_env_t *env, lpp_t *lpp, be_ilpsched_irn
                                if (get_nodes_block(pred) != block_node->irn && consider_for_sched(env->arch_env, pred)) {
                                        be_ilpsched_set_type_info(env, pred, var_obst);
                                        if (! na->is_dummy_node) {
-                                               ilp_livein_node_t *entry = obstack_alloc(var_obst, sizeof(*entry));
+                                               ilp_livein_node_t *entry = OALLOC(var_obst, ilp_livein_node_t);
                                                entry->irn = pred;
                                                entry->a   = NULL;
                                                pset_insert(ba->livein_nodes, entry, (unsigned)get_irn_idx(pred));
index 8c31ef2..e9631e6 100644 (file)
@@ -39,7 +39,6 @@ void be_info_new_node(ir_node *node)
 {
        struct obstack *obst;
        backend_info_t *info;
-       sched_info_t   *sinfo;
 
        if (is_Anchor(node))
                return;
@@ -48,12 +47,7 @@ void be_info_new_node(ir_node *node)
                return;
 
        obst  = get_irg_obstack(current_ir_graph);
-       info  = obstack_alloc(obst, sizeof(*info));
-       sinfo = &info->sched_info;
-
-       memset(info, 0, sizeof(*info));
-       sinfo->next = NULL;
-       sinfo->prev = NULL;
+       info  = OALLOCZ(obst, backend_info_t);
 
        if (is_Phi(node)) {
                info->out_infos = NEW_ARR_D(reg_out_info_t, obst, 1);
index b8bc71c..ebe4f4a 100644 (file)
@@ -85,8 +85,7 @@ be_insn_t *be_scan_insn(const be_insn_env_t *env, ir_node *irn)
        int i, n;
        int pre_colored = 0;
 
-       insn = obstack_alloc(obst, sizeof(insn[0]));
-       memset(insn, 0, sizeof(insn[0]));
+       insn = OALLOCZ(obst, be_insn_t);
 
        insn->irn       = irn;
        insn->next_insn = sched_next(irn);
index 83d27d5..b3875e7 100644 (file)
@@ -553,7 +553,7 @@ static void gen_assure_different_pattern(ir_node *irn, ir_node *other_different,
        /* insert the other different and it's copies into the map */
        entry = ir_nodemap_get(op_set, other_different);
        if (! entry) {
-               entry      = obstack_alloc(&env->obst, sizeof(*entry));
+               entry      = OALLOC(&env->obst, op_copy_assoc_t);
                entry->cls = cls;
                ir_nodeset_init(&entry->copies);
 
index 6446173..e654654 100644 (file)
@@ -133,9 +133,7 @@ static allocation_info_t *get_allocation_info(ir_node *node)
 {
        allocation_info_t *info;
        if (!irn_visited_else_mark(node)) {
-               size_t size = sizeof(info[0]) + n_regs * sizeof(info->prefs[0]);
-               info = obstack_alloc(&obst, size);
-               memset(info, 0, size);
+               info = OALLOCFZ(&obst, allocation_info_t, prefs, n_regs);
                info->current_value  = node;
                info->original_value = node;
                set_irn_link(node, info);
@@ -155,9 +153,7 @@ static block_info_t *get_block_info(ir_node *block)
 
        assert(is_Block(block));
        if (!irn_visited_else_mark(block)) {
-               size_t size = sizeof(info[0]) + n_regs * sizeof(info->assignments[0]);
-               info = obstack_alloc(&obst, size);
-               memset(info, 0, size);
+               info = OALLOCFZ(&obst, block_info_t, assignments, n_regs);
                set_irn_link(block, info);
        } else {
                info = get_irn_link(block);
@@ -173,8 +169,7 @@ static const arch_register_req_t *get_default_req_current_cls(void)
 {
        if (default_cls_req == NULL) {
                struct obstack      *obst = get_irg_obstack(irg);
-               arch_register_req_t *req  = obstack_alloc(obst, sizeof(*req));
-               memset(req, 0, sizeof(*req));
+               arch_register_req_t *req  = OALLOCZ(obst, arch_register_req_t);
 
                req->type = arch_register_req_type_normal;
                req->cls  = cls;
index 49b258f..ecb11e4 100644 (file)
@@ -453,11 +453,8 @@ ir_node *be_new_MemPerm(const arch_env_t *arch_env, ir_node *bl, int n, ir_node
        }
 
        attr = get_irn_attr(irn);
-
-       attr->in_entities = obstack_alloc(irg->obst, n * sizeof(attr->in_entities[0]));
-       memset(attr->in_entities, 0, n * sizeof(attr->in_entities[0]));
-       attr->out_entities = obstack_alloc(irg->obst, n*sizeof(attr->out_entities[0]));
-       memset(attr->out_entities, 0, n*sizeof(attr->out_entities[0]));
+       attr->in_entities  = OALLOCNZ(irg->obst, ir_entity*, n);
+       attr->out_entities = OALLOCNZ(irg->obst, ir_entity*, n);
 
        return irn;
 }
@@ -1280,8 +1277,7 @@ static const arch_register_req_t *phi_get_irn_reg_req(const ir_node *node,
                        assert(req->cls != NULL);
 
                        if (req->type != arch_register_req_type_normal) {
-                               arch_register_req_t *nreq = obstack_alloc(obst, sizeof(*nreq));
-                               memset(nreq, 0, sizeof(*nreq));
+                               arch_register_req_t *nreq = OALLOCZ(obst, arch_register_req_t);
                                nreq->type = arch_register_req_type_normal;
                                nreq->cls  = req->cls;
                                req        = nreq;
index 5f5e8a0..afcfc38 100644 (file)
@@ -154,7 +154,7 @@ static int normal_tree_cost(ir_node* irn, instance_t *inst)
                int            i;
                ir_node*       block = get_nodes_block(irn);
 
-               fc = obstack_alloc(&inst->obst, sizeof(*fc) + sizeof(*fc->costs) * arity);
+               fc = OALLOCF(&inst->obst, flag_and_cost, costs, arity);
                fc->no_root = 0;
                costs = fc->costs;
 
index 93ad724..93bae4a 100644 (file)
@@ -91,7 +91,7 @@ static inline usage_stats_t *get_or_set_usage_stats(reg_pressure_selector_env_t
        usage_stats_t *us = get_irn_link(irn);
 
        if(!us) {
-               us                   = obstack_alloc(&env->obst, sizeof(us[0]));
+               us                   = OALLOC(&env->obst, usage_stats_t);
                us->irn              = irn;
                us->already_consumed = 0;
                us->max_hops         = INT_MAX;
index 5ab8513..7f9348f 100644 (file)
@@ -881,7 +881,7 @@ static void build_kill_edges(rss_t *rss, pset *epk) {
 
                foreach_plist(rirn->pkiller_list, k_el) {
                        ir_node    *pkiller = plist_element_get_value(k_el);
-                       rss_edge_t *ke      = obstack_alloc(phase_obst(&rss->ph), sizeof(*ke));
+                       rss_edge_t *ke      = OALLOC(phase_obst(&rss->ph), rss_edge_t);
 
                        ke->src  = irn;
                        ke->tgt  = pkiller;
@@ -950,7 +950,7 @@ static void compute_bipartite_decomposition(rss_t *rss) {
 
                DBG((rss->dbg, LEVEL_2, "\t\t%+F choosen:\n", u_irn));
 
-               cbc     = obstack_alloc(phase_obst(&rss->ph), sizeof(*cbc));
+               cbc     = OALLOC(phase_obst(&rss->ph), cbc_t);
                cbc->nr = cur_num++;
 
                /* initialize S_cb */
@@ -1184,8 +1184,7 @@ static void compute_killing_function(rss_t *rss) {
 
                /* while X not empty */
                while (ir_nodeset_size(&x) > 0) {
-                       child_t *t = obstack_alloc(&obst, sizeof(*t));
-                       memset(t, 0, sizeof(*t));
+                       child_t *t = OALLOCZ(&obst, child_t);
 
                        t = select_child_max_cost(rss, &x, &y, t, cbc);
 
@@ -1265,7 +1264,7 @@ static inline void add_dvg_edge(rss_t *rss, dvg_t *dvg, const ir_node *src, cons
        key.tgt = (ir_node *) tgt;
        if (NULL != pset_find(dvg->edges, &key, HASH_RSS_EDGE(&key))) {
                /* add the edge to the DVG */
-               dvg_edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*dvg_edge));
+               dvg_edge = OALLOC(phase_obst(&rss->ph), rss_edge_t);
 
                dvg_edge->src  = (ir_node *) src;
                dvg_edge->tgt  = (ir_node *) tgt;
@@ -1314,7 +1313,7 @@ static void compute_dvg(rss_t *rss, dvg_t *dvg) {
                                There is an edge (u, v) in the DVG iff v is a descendant of the killer(u).
                        */
                        if (BSEARCH_IRN_ARR(v_irn, u_kill->descendants)) {
-                               rss_edge_t *dvg_edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*dvg_edge));
+                               rss_edge_t *dvg_edge = OALLOC(phase_obst(&rss->ph), rss_edge_t);
                                rss_edge_t key;
 
                                /* insert the user into the DVG and append it to the user list of u */
@@ -1579,7 +1578,7 @@ static ir_nodeset_t *compute_maximal_antichain(rss_t *rss, dvg_t *dvg, int itera
                        int       xj      = idx_map[j];
                        ir_node   *xj_irn = get_idx_irn(rss->irg, xj);
                        rss_irn_t *xj_rss = get_rss_irn(rss, xj_irn);
-                       chain_t   *c      = obstack_alloc(phase_obst(&rss->ph), sizeof(*c));
+                       chain_t   *c      = OALLOC(phase_obst(&rss->ph), chain_t);
                        int       source;
 
                        /* there was no source for j -> we have a source of a new chain */
@@ -1991,7 +1990,7 @@ static void perform_value_serialization_heuristic(rss_t *rss) {
        sat_vals  = compute_maximal_antichain(rss, &dvg, iteration++);
        while (sat_vals && (ir_nodeset_size(sat_vals) > available_regs)) {
                serialization_t *ser, best_ser;
-               rss_edge_t      *edge = obstack_alloc(phase_obst(&rss->ph), sizeof(*edge));
+               rss_edge_t      *edge = OALLOC(phase_obst(&rss->ph), rss_edge_t);
                ir_node         *dep_src, *dep_tgt;
 
                best_ser.edge = edge;
index 662f2c9..5815e6e 100644 (file)
@@ -132,12 +132,7 @@ void workset_print(const workset_t *w)
  */
 static workset_t *new_workset(void)
 {
-       workset_t *res;
-       size_t     size = sizeof(*res) + n_regs * sizeof(res->vals[0]);
-
-       res  = obstack_alloc(&obst, size);
-       memset(res, 0, size);
-       return res;
+       return OALLOCFZ(&obst, workset_t, vals, n_regs);
 }
 
 /**
@@ -145,10 +140,8 @@ static workset_t *new_workset(void)
  */
 static workset_t *workset_clone(workset_t *workset)
 {
-       workset_t *res;
-       size_t size = sizeof(*res) + n_regs * sizeof(res->vals[0]);
-       res = obstack_alloc(&obst, size);
-       memcpy(res, workset, size);
+       workset_t *res = OALLOCF(&obst, workset_t, vals, n_regs);
+       memcpy(res, workset, sizeof(*res) + n_regs * sizeof(res->vals[0]));
        return res;
 }
 
@@ -262,12 +255,9 @@ typedef struct _block_info_t
 } block_info_t;
 
 
-static void *new_block_info(void)
+static block_info_t *new_block_info(void)
 {
-       block_info_t *res = obstack_alloc(&obst, sizeof(res[0]));
-       memset(res, 0, sizeof(res[0]));
-
-       return res;
+       return OALLOCZ(&obst, block_info_t);
 }
 
 #define get_block_info(block)        ((block_info_t *)get_irn_link(block))
index 8da5a8e..bdc99fc 100644 (file)
@@ -157,21 +157,15 @@ static inline void workset_print(const workset_t *w)
  * Alloc a new workset on obstack @p ob with maximum size @p max
  */
 static inline workset_t *new_workset(belady_env_t *env, struct obstack *ob) {
-       workset_t *res;
-       size_t size = sizeof(*res) + (env->n_regs)*sizeof(res->vals[0]);
-       res = obstack_alloc(ob, size);
-       memset(res, 0, size);
-       return res;
+       return OALLOCFZ(ob, workset_t, vals, env->n_regs);
 }
 
 /**
  * Alloc a new instance on obstack and make it equal to @param ws
  */
 static inline workset_t *workset_clone(belady_env_t *env, struct obstack *ob, workset_t *ws) {
-       workset_t *res;
-       size_t size = sizeof(*res) + (env->n_regs)*sizeof(res->vals[0]);
-       res = obstack_alloc(ob, size);
-       memcpy(res, ws, size);
+       workset_t *res = OALLOCF(ob, workset_t, vals, env->n_regs);
+       memcpy(res, ws, sizeof(*res) + (env->n_regs)*sizeof(res->vals[0]));
        return res;
 }
 
@@ -296,13 +290,12 @@ typedef struct _block_info_t {
 static inline void *new_block_info(belady_env_t *bel, int id)
 {
        ir_node      *bl  = bel->blocks[id];
-       block_info_t *res = obstack_alloc(&bel->ob, sizeof(*res));
-       memset(res, 0, sizeof(res[0]));
+       block_info_t *res = OALLOCZ(&bel->ob, block_info_t);
        res->first_non_in = NULL;
-       res->last_ins = NULL;
-       res->bel = bel;
-       res->bl  = bl;
-       res->id  = id;
+       res->last_ins     = NULL;
+       res->bel          = bel;
+       res->bl           = bl;
+       res->id           = id;
        res->exec_freq    = get_block_execfreq(bel->ef, bl);
        res->reload_cost  = bel->arch->reload_cost * res->exec_freq;
        res->free_at_jump = bel->n_regs;
@@ -442,8 +435,7 @@ struct _bring_in_t {
 
 static inline bring_in_t *new_bring_in(block_info_t *bi, ir_node *irn, const next_use_t *use)
 {
-       bring_in_t *br    = obstack_alloc(&bi->bel->ob, sizeof(br[0]));
-
+       bring_in_t *br      = OALLOC(&bi->bel->ob, bring_in_t);
        br->irn             = irn;
        br->bi              = bi;
        br->first_use       = use->irn;
@@ -831,7 +823,7 @@ static inline const workset_t *get_end_state(global_end_state_t *ges, block_info
 static block_state_t *new_block_state(global_end_state_t *ges, block_info_t *bi)
 {
        block_state_t *bs = get_block_state(ges, bi);
-       block_state_t *nw = obstack_alloc(&ges->obst, sizeof(nw[0]));
+       block_state_t *nw = OALLOC(&ges->obst, block_state_t);
 
        nw->next_intern = bs;
        nw->next        = ges->bs_top;
@@ -854,7 +846,7 @@ static block_state_t *new_block_state(global_end_state_t *ges, block_info_t *bi)
 
 static irn_action_t *new_irn_action(global_end_state_t *ges, ir_node *irn, const ir_node *bl)
 {
-       irn_action_t *ia = obstack_alloc(&ges->obst, sizeof(ia[0]));
+       irn_action_t *ia = OALLOC(&ges->obst, irn_action_t);
 
        ia->irn  = irn;
        ia->bl   = bl;
@@ -1414,8 +1406,8 @@ static void global_assign(belady_env_t *env)
        ges.version      = ver_make_newer(ver_oldest);
        ges.succ_phis    = bitset_irg_obstack_alloc(&ges.obst, env->irg);
        ges.committed    = bitset_obstack_alloc(&ges.obst, env->n_blocks);
-       ges.bs_tops      = obstack_alloc(&ges.obst, sizeof(ges.bs_tops[0])      * env->n_blocks);
-       ges.bs_tops_vers = obstack_alloc(&ges.obst, sizeof(ges.bs_tops_vers[0]) * env->n_blocks);
+       ges.bs_tops      = OALLOCN(&ges.obst, block_state_t*, env->n_blocks);
+       ges.bs_tops_vers = OALLOCN(&ges.obst, unsigned,       env->n_blocks);
 
        /* invalidate all state stack pointer versions */
        for (i = 0; i < env->n_blocks; ++i) {
index 4ef0a51..a8c70fa 100644 (file)
@@ -112,8 +112,7 @@ static bool                         should_have_reached_fixpoint;
 
 static worklist_t *new_worklist(void)
 {
-       worklist_t *worklist = obstack_alloc(&obst, sizeof(worklist[0]));
-       memset(worklist, 0, sizeof(worklist[0]));
+       worklist_t *worklist = OALLOCZ(&obst, worklist_t);
 
        INIT_LIST_HEAD(&worklist->live_values);
        worklist->n_live_values    = 0;
@@ -137,8 +136,7 @@ static block_info_t *get_block_info(ir_node *block)
        if (info != NULL)
                return info;
 
-       info = obstack_alloc(&obst, sizeof(info[0]));
-       memset(info, 0, sizeof(info[0]));
+       info = OALLOCZ(&obst, block_info_t);
        set_irn_link(block, info);
        return info;
 }
@@ -200,8 +198,7 @@ static void fill_and_activate_worklist(worklist_t *new_worklist,
                if (irn_visited_else_mark(value))
                        continue;
 
-               new_entry = obstack_alloc(&obst, sizeof(new_entry[0]));
-               memset(new_entry, 0, sizeof(new_entry[0]));
+               new_entry = OALLOCZ(&obst, worklist_entry_t);
 
                new_entry->value = value;
                if (reload_point != NULL) {
@@ -223,15 +220,13 @@ static worklist_t *duplicate_worklist(const worklist_t *worklist)
        worklist_t       *new_worklist;
        struct list_head *entry;
 
-       new_worklist = obstack_alloc(&obst, sizeof(new_worklist[0]));
-       memset(new_worklist, 0, sizeof(new_worklist[0]));
+       new_worklist = OALLOCZ(&obst, worklist_t);
        INIT_LIST_HEAD(&new_worklist->live_values);
        new_worklist->n_live_values = worklist->n_live_values;
 
        list_for_each(entry, &worklist->live_values) {
                worklist_entry_t *wl_entry  = list_entry(entry, worklist_entry_t, head);
-               worklist_entry_t *new_entry
-                       = obstack_alloc(&obst, sizeof(new_entry[0]));
+               worklist_entry_t *new_entry     = OALLOC(&obst, worklist_entry_t);
 
                memcpy(new_entry, wl_entry, sizeof(new_entry[0]));
                list_add_tail(&new_entry->head, &new_worklist->live_values);
@@ -283,8 +278,7 @@ static loop_info_t *get_loop_info(ir_loop *loop)
        if (info != NULL)
                return info;
 
-       info = obstack_alloc(&obst, sizeof(info[0]));
-       memset(info, 0, sizeof(info[0]));
+       info = OALLOCZ(&obst, loop_info_t);
        info->loop = loop;
        loop->link = info;
        return info;
@@ -330,8 +324,7 @@ static void construct_loop_edges(ir_node *block, void *data)
                do {
                        loop_info_t *l_info = get_loop_info(l);
 
-                       edge = obstack_alloc(&obst, sizeof(edge[0]));
-                       memset(edge, 0, sizeof(edge[0]));
+                       edge = OALLOCZ(&obst, loop_edge_t);
                        edge->block = block;
                        edge->pos   = i;
 
@@ -410,9 +403,7 @@ static void val_used(worklist_t *worklist, ir_node *value, ir_node *sched_point)
                list_del(&entry->head);
        } else {
                if (entry == NULL) {
-                       entry        = obstack_alloc(&obst, sizeof(entry[0]));
-                       memset(entry, 0, sizeof(entry[0]));
-
+                       entry        = OALLOCZ(&obst, worklist_entry_t);
                        entry->value = value;
                        set_irn_link(value, entry);
                }
@@ -747,9 +738,7 @@ static void worklist_append(worklist_t *worklist, ir_node *value,
        }
 #endif
 
-       entry = obstack_alloc(&obst, sizeof(*entry));
-       memset(entry, 0, sizeof(entry[0]));
-
+       entry = OALLOCZ(&obst, worklist_entry_t);
        entry->value                   = value;
        entry->reload_point            = reload_point;
        entry->unused_livethrough_loop = unused_livethrough_loop;
index 7faff45..d65e61c 100644 (file)
@@ -182,7 +182,7 @@ static spill_t *collect_memphi(be_fec_env_t *env, ir_node *node,
                }
 
                /* add an affinity edge */
-               affinty_edge           = obstack_alloc(&env->obst, sizeof(affinty_edge[0]));
+               affinty_edge           = OALLOC(&env->obst, affinity_edge_t);
                affinty_edge->affinity = get_block_execfreq(exec_freq, get_nodes_block(arg));
                affinty_edge->slot1    = res->spillslot;
                affinty_edge->slot2    = arg_spill->spillslot;
@@ -643,7 +643,7 @@ static void assign_spillslots(be_fec_env_t *env)
 
                                        memperm = get_memperm(env, predblock);
 
-                                       entry = obstack_alloc(&env->obst, sizeof(entry[0]));
+                                       entry = OALLOC(&env->obst, memperm_entry_t);
                                        entry->node = node;
                                        entry->pos = i;
                                        entry->in = argslot->entity;
index ec76834..1b19fcc 100644 (file)
@@ -226,7 +226,7 @@ void be_add_spill(spill_env_t *env, ir_node *to_spill, ir_node *after)
                }
        }
 
-       spill         = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill         = OALLOC(&env->obst, spill_t);
        spill->after  = after;
        spill->next   = spill_info->spills;
        spill->spill  = NULL;
@@ -243,7 +243,7 @@ void be_add_remat(spill_env_t *env, ir_node *to_spill, ir_node *before,
        spill_info = get_spillinfo(env, to_spill);
 
        /* add the remat information */
-       reloader                   = obstack_alloc(&env->obst, sizeof(reloader[0]));
+       reloader                   = OALLOC(&env->obst, reloader_t);
        reloader->next             = spill_info->reloaders;
        reloader->reloader         = before;
        reloader->rematted_node    = rematted_node;
@@ -282,7 +282,7 @@ void be_add_reload2(spill_env_t *env, ir_node *to_spill, ir_node *before,
        assert(!is_Proj(before) && !be_is_Keep(before));
 
        /* put reload into list */
-       rel                   = obstack_alloc(&env->obst, sizeof(rel[0]));
+       rel                   = OALLOC(&env->obst, reloader_t);
        rel->next             = info->reloaders;
        rel->reloader         = before;
        rel->rematted_node    = NULL;
@@ -493,7 +493,7 @@ static void spill_phi(spill_env_t *env, spill_info_t *spillinfo)
        }
 
        /* override or replace spills list... */
-       spill         = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill         = OALLOC(&env->obst, spill_t);
        spill->after  = skip_keeps_phis(phi);
        spill->spill  = new_r_Phi(block, arity, ins, mode_M);
        spill->next   = NULL;
@@ -779,7 +779,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
         */
        if(!sched_is_scheduled(insn)) {
                /* override spillinfos or create a new one */
-               spill_t *spill = obstack_alloc(&env->obst, sizeof(spill[0]));
+               spill_t *spill = OALLOC(&env->obst, spill_t);
                spill->after = NULL;
                spill->next  = NULL;
                spill->spill = new_NoMem();
@@ -828,7 +828,7 @@ static void determine_spill_costs(spill_env_t *env, spill_info_t *spillinfo)
        }
 
        /* override spillinfos or create a new one */
-       spill        = obstack_alloc(&env->obst, sizeof(spill[0]));
+       spill        = OALLOC(&env->obst, spill_t);
        spill->after = skip_keeps_phis(to_spill);
        spill->next  = NULL;
        spill->spill = NULL;
index f42ba16..043e302 100644 (file)
@@ -79,8 +79,7 @@ typedef struct block_info_t {
 static inline
 block_info_t *new_block_info(struct obstack *obst, ir_node *block)
 {
-       block_info_t *res = obstack_alloc(obst, sizeof(*res));
-       memset(res, 0, sizeof(res[0]));
+       block_info_t *res = OALLOCZ(obst, block_info_t);
 
        assert(is_Block(block));
        set_irn_link(block, res);
@@ -99,8 +98,7 @@ block_info_t *get_block_info(ir_node *block)
 static inline
 spill_info_t *create_spill_info(minibelady_env_t *env, ir_node *state)
 {
-       spill_info_t *spill_info = obstack_alloc(&env->obst, sizeof(spill_info[0]));
-       memset(spill_info, 0, sizeof(spill_info[0]));
+       spill_info_t *spill_info = OALLOCZ(&env->obst, spill_info_t);
        spill_info->value = state;
        spill_info->reloads = NEW_ARR_F(ir_node*, 0);
 
index 1a279a0..e49a635 100644 (file)
@@ -114,7 +114,7 @@ typedef struct _msg_info_t {
 static void *make_msg_info(const firm_dbg_module_t *mod, const char *fmt, va_list args)
 {
   static const char msg_header[] = "%s(%d) %s: ";
-  msg_info_t *res = obstack_alloc(&dbg_obst, sizeof(*res));
+  msg_info_t *res = OALLOC(&dbg_obst, msg_info_t);
 
   obstack_grow(&dbg_obst, msg_header, sizeof(msg_header) - 1);
   ir_obst_vprintf(&dbg_obst, fmt, args);
index 1f590ab..60a2b25 100644 (file)
@@ -131,7 +131,7 @@ static int default_evaluate(insn_kind kind, tarval *tv) {
  * emit a LEA (or an Add) instruction
  */
 static instruction *emit_LEA(mul_env *env, instruction *a, instruction *b, unsigned shift) {
-       instruction *res = obstack_alloc(&env->obst, sizeof(*res));
+       instruction *res = OALLOC(&env->obst, instruction);
        res->kind = shift > 0 ? LEA : ADD;
        res->in[0] = a;
        res->in[1] = b;
@@ -145,7 +145,7 @@ static instruction *emit_LEA(mul_env *env, instruction *a, instruction *b, unsig
  * emit a SHIFT (or an Add or a Zero) instruction
  */
 static instruction *emit_SHIFT(mul_env *env, instruction *a, unsigned shift) {
-       instruction *res = obstack_alloc(&env->obst, sizeof(*res));
+       instruction *res = OALLOC(&env->obst, instruction);
        if (shift == env->bits) {
                /* a 2^bits with bits resolution is a zero */
                res->kind = ZERO;
@@ -172,7 +172,7 @@ static instruction *emit_SHIFT(mul_env *env, instruction *a, unsigned shift) {
  * emit a SUB instruction
  */
 static instruction *emit_SUB(mul_env *env, instruction *a, instruction *b) {
-       instruction *res = obstack_alloc(&env->obst, sizeof(*res));
+       instruction *res = OALLOC(&env->obst, instruction);
        res->kind = SUB;
        res->in[0] = a;
        res->in[1] = b;
@@ -186,7 +186,7 @@ static instruction *emit_SUB(mul_env *env, instruction *a, instruction *b) {
  * emit the ROOT instruction
  */
 static instruction *emit_ROOT(mul_env *env, ir_node *root_op) {
-       instruction *res = obstack_alloc(&env->obst, sizeof(*res));
+       instruction *res = OALLOC(&env->obst, instruction);
        res->kind = ROOT;
        res->in[0] = NULL;
        res->in[1] = NULL;
index 72babd6..c02d07d 100644 (file)
@@ -290,7 +290,7 @@ static void dump_grg_node(ir_node *n, grgen_dumpinfo_t *dump_info, FILE *fp)
 
        // Else generate new node name and dump the node
 
-       node_name = obstack_alloc(&(dump_info -> node_names), MAX_NODENAME_LEN);
+       node_name = OALLOCN(&dump_info->node_names, char, MAX_NODENAME_LEN);
 
        sprintf(node_name, "%s%ld", get_op_name(get_irn_op(n)), get_irn_node_nr(n));
        fprintf(fp, "%s%s : %s;\n", indent, node_name, get_op_name(get_irn_op(n)));
@@ -321,8 +321,8 @@ static void dump_grg_egde(ir_node *n, int n_edge, grgen_dumpinfo_t *dump_info, F
 
        if((nodes_edge_names = pmap_get(dump_info -> edge_name_map, n)) == NULL)
        {
-               nodes_edge_names = (char **) obstack_alloc(&(dump_info->node_names), (get_irn_arity(n) + 1) * sizeof(char *));
-               memset(nodes_edge_names, 0, (get_irn_arity(n) + 1) * sizeof(char *));
+               size_t const count = get_irn_arity(n) + 1;
+               nodes_edge_names = OALLOCNZ(&dump_info->node_names, char*, count);
                pmap_insert(dump_info->edge_name_map, n, nodes_edge_names);
        }
 
@@ -336,7 +336,7 @@ static void dump_grg_egde(ir_node *n, int n_edge, grgen_dumpinfo_t *dump_info, F
        char edge_name[50], *edge_name_obst;
 
        sprintf(edge_name, "pos%d_%d", n_edge + 1, edge_counter++);
-       edge_name_obst = obstack_alloc(&(dump_info->node_names), strlen(edge_name) + 1);
+       edge_name_obst = OALLOCN(&dump_info->node_names, char, strlen(edge_name) + 1);
        strcpy(edge_name_obst, edge_name);
        nodes_edge_names[n_edge + 1] = edge_name_obst;
 
@@ -374,7 +374,7 @@ static void dump_grgen_mode(ir_node *n, grgen_dumpinfo_t *dump_info, FILE *fp, i
 
        if(pmap_get(dump_info->mode_edge_map, n) == NULL)
        {
-               char *edge_name_obst = obstack_alloc(&(dump_info->node_names), strlen(edge_name) + 1);
+               char *edge_name_obst = OALLOCN(&dump_info->node_names, char, strlen(edge_name) + 1);
                strcpy(edge_name_obst, edge_name);
                pmap_insert(dump_info->mode_edge_map, n, edge_name_obst);
        }
@@ -397,7 +397,7 @@ static char *dump_grgen_mode_node(ir_mode *irn_mode, grgen_dumpinfo_t *dump_info
        if(!pmap_contains(dump_info -> mode_name_map, irn_mode))
        {
                // No, create a new mode-node
-               mode_node_name = obstack_alloc(&(dump_info -> mode_names), MAX_NODENAME_LEN);
+               mode_node_name = OALLOCN(&dump_info->mode_names, char, MAX_NODENAME_LEN);
                sprintf(mode_node_name, "mode_%s_node", mode_name);
                pmap_insert(dump_info -> mode_name_map, irn_mode, mode_node_name);
                fprintf(fp, "%s%s : Mode_%s;\n", indent, mode_node_name, mode_name);
index 7ead8fe..758c811 100644 (file)
@@ -82,7 +82,7 @@ static block_entry_t *block_find_entry(ir_node *block, blk_collect_data_t *ctx)
        if (elem)
                return elem;
 
-       elem = obstack_alloc(&ctx->obst, sizeof(*elem));
+       elem = OALLOC(&ctx->obst, block_entry_t);
 
        elem->block      = block;
        elem->phi_list   = NEW_ARR_F(ir_node *, 0);
index 4d6b205..85b7dcc 100644 (file)
@@ -52,6 +52,7 @@
 #include "lc_parser_t.h"
 #include "hashptr.h"
 #include "lc_printf.h"
+#include "xmalloc.h"
 
 #define ERR_STRING "In argument \"%s\": "
 
@@ -221,7 +222,7 @@ lc_opt_entry_t *lc_opt_get_grp(lc_opt_entry_t *parent, const char *name)
        lc_opt_entry_t *ent = lc_opt_find_grp(parent, name, NULL);
 
        if(!ent) {
-               ent = obstack_alloc(&obst, sizeof(*ent));
+               ent = OALLOC(&obst, lc_opt_entry_t);
                init_entry(ent, parent, name, "");
                init_grp(ent, NULL);
        }
@@ -242,7 +243,7 @@ lc_opt_entry_t *lc_opt_add_opt(lc_opt_entry_t *parent,
                lc_opt_entry_t *ent = lc_opt_find_opt(parent, name, NULL);
 
                if(!ent) {
-                       res = obstack_alloc(&obst, sizeof(*ent));
+                       res = OALLOC(&obst, lc_opt_entry_t);
                        init_entry(res, parent, name, desc);
                        init_opt(res, type, value, length, cb, dump, dump_vals, err);
                } else
index 97f633b..59ff27f 100644 (file)
@@ -261,7 +261,7 @@ typedef struct _wlk_env_t {
 static cl_entry *get_Call_entry(ir_node *call, wlk_env *env) {
        cl_entry *res = get_irn_link(call);
        if (res == NULL) {
-               cl_entry *res = obstack_alloc(&env->obst, sizeof(*res));
+               cl_entry *res = OALLOC(&env->obst, cl_entry);
                res->next  = env->cl_list;
                res->call  = call;
                res->copyb = NULL;
index 8060ab0..d2ebc56 100644 (file)
@@ -156,7 +156,7 @@ static void find_copyb_nodes(ir_node *irn, void *ctx) {
                return;
 
        /* ok, link it in */
-       entry = obstack_alloc(&env->obst, sizeof(*entry));
+       entry = OALLOC(&env->obst, entry_t);
        entry->copyb = irn;
        INIT_LIST_HEAD(&entry->list);
        set_irn_link(irn, entry);
index 1a21834..9ce41fb 100644 (file)
@@ -281,9 +281,7 @@ static void prepare_links(ir_node *node, void *env)
        if (mode == lenv->params->high_signed ||
                mode == lenv->params->high_unsigned) {
                /* ok, found a node that will be lowered */
-               link = obstack_alloc(&lenv->obst, sizeof(*link));
-
-               memset(link, 0, sizeof(*link));
+               link = OALLOCZ(&lenv->obst, node_entry_t);
 
                idx = get_irn_idx(node);
                if (idx >= lenv->n_entries) {
index eae8270..8b22216 100644 (file)
@@ -666,7 +666,7 @@ static inline void add_to_worklist(partition_t *X, environment_t *env) {
  * @return a newly allocated partition
  */
 static inline partition_t *new_partition(environment_t *env) {
-       partition_t *part = obstack_alloc(&env->obst, sizeof(*part));
+       partition_t *part = OALLOC(&env->obst, partition_t);
 
        INIT_LIST_HEAD(&part->Leader);
        INIT_LIST_HEAD(&part->Follower);
@@ -725,7 +725,7 @@ static inline lattice_elem_t get_partition_type(const partition_t *X) {
  */
 static node_t *create_partition_node(ir_node *irn, partition_t *part, environment_t *env) {
        /* create a partition node and place it in the partition */
-       node_t *node = obstack_alloc(&env->obst, sizeof(*node));
+       node_t *node = OALLOC(&env->obst, node_t);
 
        INIT_LIST_HEAD(&node->node_list);
        INIT_LIST_HEAD(&node->cprop_list);
index 72e0b63..fae75f1 100644 (file)
@@ -560,7 +560,7 @@ void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback)
   obstack_init(&obst);
   elist = NULL;
 
-  env = obstack_alloc(&obst, sizeof(*env));
+  env = OALLOC(&obst, walk_env_t);
   env->found_allocs = NULL;
   env->dead_allocs  = NULL;
   env->callback     = callback;
@@ -586,7 +586,7 @@ void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback)
 
       elist = env;
 
-      env = obstack_alloc(&obst, sizeof(*env));
+      env = OALLOC(&obst, walk_env_t);
       env->found_allocs = NULL;
       env->dead_allocs  = NULL;
       env->callback     = callback;
index ec141db..056e4d4 100644 (file)
@@ -160,7 +160,7 @@ static block_info *get_block_info(ir_node *block) {
  * @param env     the environment
  */
 static void alloc_blk_info(ir_node *block, pre_env *env) {
-       block_info *info = obstack_alloc(env->obst, sizeof(*info));
+       block_info *info = OALLOC(env->obst, block_info);
 
        set_irn_link(block, info);
        info->exp_gen   = ir_valueset_new(16);
@@ -719,7 +719,7 @@ static void eliminate(ir_node *irn, void *ctx) {
                        ir_node *expr = ir_valueset_lookup(bl->avail_out, value);
 
                        if (expr != NULL && expr != irn) {
-                               elim_pair *p = obstack_alloc(env->obst, sizeof(*p));
+                               elim_pair *p = OALLOC(env->obst, elim_pair);
 
                                p->old_node = irn;
                                p->new_node = expr;
index 3cf50ab..dd0231e 100644 (file)
@@ -113,8 +113,7 @@ static ldst_info_t *get_ldst_info(ir_node *node, struct obstack *obst) {
        ldst_info_t *info = get_irn_link(node);
 
        if (! info) {
-               info = obstack_alloc(obst, sizeof(*info));
-               memset(info, 0, sizeof(*info));
+               info = OALLOCZ(obst, ldst_info_t);
                set_irn_link(node, info);
        }
        return info;
@@ -127,8 +126,7 @@ static block_info_t *get_block_info(ir_node *node, struct obstack *obst) {
        block_info_t *info = get_irn_link(node);
 
        if (! info) {
-               info = obstack_alloc(obst, sizeof(*info));
-               memset(info, 0, sizeof(*info));
+               info = OALLOCZ(obst, block_info_t);
                set_irn_link(node, info);
        }
        return info;
index ec5c499..4ecf135 100644 (file)
@@ -277,7 +277,7 @@ static int cmp_opcode(const void *elt, const void *key, size_t size) {
  * @param env         the environment
  */
 static partition_t *create_partition(ir_node *meet_block, environment_t *env) {
-       partition_t *part = obstack_alloc(&env->obst, sizeof(*part));
+       partition_t *part = OALLOC(&env->obst, partition_t);
 
        INIT_LIST_HEAD(&part->blocks);
        part->meet_block = meet_block;
@@ -296,7 +296,7 @@ static partition_t *create_partition(ir_node *meet_block, environment_t *env) {
  * @param env        the environment
  */
 static block_t *create_block(ir_node *block, int meet_input, partition_t *partition, environment_t *env) {
-       block_t *bl = obstack_alloc(&env->obst, sizeof(*bl));
+       block_t *bl = OALLOC(&env->obst, block_t);
 
        set_irn_link(block, bl);
 
@@ -328,7 +328,7 @@ static block_t *create_block(ir_node *block, int meet_input, partition_t *partit
  * @param env    the environment
  */
 static node_t *create_node(ir_node *irn, block_t *block, environment_t *env) {
-       node_t *node = obstack_alloc(&env->obst, sizeof(*node));
+       node_t *node = OALLOC(&env->obst, node_t);
 
        node->node     = irn;
        node->is_input = 0;
@@ -347,7 +347,7 @@ static node_t *create_node(ir_node *irn, block_t *block, environment_t *env) {
  * @param env    the environment
  */
 static void add_pair(block_t *block, ir_node *irn, int idx, environment_t *env) {
-       pair_t *pair = obstack_alloc(&env->obst, sizeof(*pair));
+       pair_t *pair = OALLOC(&env->obst, pair_t);
 
        pair->next  = block->input_pairs;
        pair->irn   = irn;
@@ -365,7 +365,7 @@ static void add_pair(block_t *block, ir_node *irn, int idx, environment_t *env)
  * @param env    the environment
  */
 static void add_phi(block_t *block, ir_node *phi, environment_t *env) {
-       phi_t *node = obstack_alloc(&env->obst, sizeof(*node));
+       phi_t *node = OALLOC(&env->obst, phi_t);
 
        node->next = block->phis;
        node->phi  = phi;
index 7156cbe..a143165 100644 (file)
@@ -703,7 +703,7 @@ void survive_dce_register_irn(survive_dce_t *sd, ir_node **place) {
        if (*place != NULL) {
                ir_node *irn      = *place;
                survive_dce_list_t *curr = pmap_get(sd->places, irn);
-               survive_dce_list_t *nw   = obstack_alloc(&sd->obst, sizeof(nw[0]));
+               survive_dce_list_t *nw   = OALLOC(&sd->obst, survive_dce_list_t);
 
                nw->next  = curr;
                nw->place = place;
@@ -1318,7 +1318,7 @@ static void collect_calls(ir_node *call, void *env) {
                if (called_irg != NULL) {
                        /* The Call node calls a locally defined method.  Remember to inline. */
                        inline_env_t *ienv  = env;
-                       call_entry   *entry = obstack_alloc(&ienv->obst, sizeof(*entry));
+                       call_entry   *entry = OALLOC(&ienv->obst, call_entry);
                        entry->call       = call;
                        entry->callee     = called_irg;
                        entry->loop_depth = 0;
@@ -1430,7 +1430,7 @@ typedef struct {
  * Allocate a new environment for inlining.
  */
 static inline_irg_env *alloc_inline_irg_env(void) {
-       inline_irg_env *env    = obstack_alloc(&temp_obst, sizeof(*env));
+       inline_irg_env *env    = OALLOC(&temp_obst, inline_irg_env);
        INIT_LIST_HEAD(&env->calls);
        env->local_weights     = NULL;
        env->n_nodes           = -2; /* do not count count Start, End */
@@ -1503,7 +1503,7 @@ static void collect_calls2(ir_node *call, void *ctx) {
                        x->recursive = 1;
 
                /* link it in the list of possible inlinable entries */
-               entry = obstack_alloc(&temp_obst, sizeof(*entry));
+               entry = OALLOC(&temp_obst, call_entry);
                entry->call       = call;
                entry->callee     = callee;
                entry->loop_depth = get_irn_loop(get_nodes_block(call))->depth;
@@ -1543,7 +1543,7 @@ inline static int is_smaller(ir_graph *callee, unsigned size) {
  */
 static call_entry *duplicate_call_entry(const call_entry *entry,
                                         ir_node *new_call, int loop_depth_delta) {
-       call_entry *nentry = obstack_alloc(&temp_obst, sizeof(*nentry));
+       call_entry *nentry = OALLOC(&temp_obst, call_entry);
        nentry->call       = new_call;
        nentry->callee     = entry->callee;
        nentry->benefice   = entry->benefice;
index 80cb818..11f5571 100644 (file)
@@ -306,7 +306,7 @@ restart:
 
        if (entry == NULL) {
                /* new address */
-               entry = obstack_alloc(&env.obst, sizeof(*entry));
+               entry = OALLOC(&env.obst, address_entry);
 
                entry->id = env.curr_adr_id++;
                ir_nodemap_insert(&env.adr_map, adr, entry);
@@ -342,7 +342,7 @@ static void prepare_blocks(ir_node *irn, void *ctx) {
        (void)ctx;
 
        if (is_Block(irn)) {
-               block_t *entry = obstack_alloc(&env.obst, sizeof(*entry));
+               block_t *entry = OALLOC(&env.obst, block_t);
                int     n;
 
                entry->memop_forward    = NULL;
@@ -451,7 +451,7 @@ static void collect_backward(ir_node *block, void *ctx) {
  * @return the allocated memop
  */
 static memop_t *alloc_memop(ir_node *irn) {
-       memop_t *m = obstack_alloc(&env.obst, sizeof(*m));
+       memop_t *m = OALLOC(&env.obst, memop_t);
 
        m->value.address = NULL;
        m->value.value   = NULL;
@@ -477,7 +477,7 @@ static memop_t *alloc_memop(ir_node *irn) {
  * @param phi  the Phi-node representing the new value
  */
 static memop_t *clone_memop_phi(memop_t *op, ir_node *phi) {
-       memop_t *m = obstack_alloc(&env.obst, sizeof(*m));
+       memop_t *m = OALLOC(&env.obst, memop_t);
 
        m->value         = op->value;
        m->value.value   = phi;
@@ -1566,9 +1566,7 @@ static int backward_antic(block_t *bl) {
 
                if (bl->trans_results == NULL) {
                        /* allocate the translate cache */
-                       unsigned size = env.curr_adr_id * sizeof(bl->trans_results[0]);
-                       bl->trans_results = obstack_alloc(&env.obst, size);
-                       memset(bl->trans_results, 0, size);
+                       bl->trans_results = OALLOCNZ(&env.obst, memop_t*, env.curr_adr_id);
                }
 
                /* check for partly redundant values */
index f1e2130..b532d07 100644 (file)
@@ -175,8 +175,7 @@ static node_entry *get_irn_ne(ir_node *irn, iv_env *env) {
        node_entry *e = get_irn_link(irn);
 
        if (e == NULL) {
-               e = obstack_alloc(&env->obst, sizeof(*e));
-               memset(e, 0, sizeof(*e));
+               e = OALLOCZ(&env->obst, node_entry);
                set_irn_link(irn, e);
        }
        return e;
@@ -480,8 +479,7 @@ static int replace(ir_node *irn, ir_node *iv, ir_node *rc, iv_env *env) {
                exchange(irn, result);
                e = get_irn_ne(result, env);
                if (e->pscc == NULL) {
-                       e->pscc = obstack_alloc(&env->obst, sizeof(*e->pscc));
-                       memset(e->pscc, 0, sizeof(*e->pscc));
+                       e->pscc = OALLOCZ(&env->obst, scc);
                        update_scc(result, e, env);
                }
                ++env->replaced;
@@ -997,10 +995,9 @@ static void dfs(ir_node *irn, iv_env *env) {
                                node->low = MIN(o->DFSnum, node->low);
                }
                if (node->low == node->DFSnum) {
-                       scc *pscc = obstack_alloc(&env->obst, sizeof(*pscc));
+                       scc *pscc = OALLOCZ(&env->obst, scc);
                        ir_node *x;
 
-                       memset(pscc, 0, sizeof(*pscc));
                        do {
                                node_entry *e;
 
index 524989c..bf602a6 100644 (file)
@@ -142,7 +142,7 @@ static void process_call(ir_node *call, ir_entity *callee, q_set *hmap) {
                        if (! hmap->map)
                                hmap->map = new_pset(entry_cmp, 8);
 
-                       key = obstack_alloc(&hmap->obst, sizeof(*key));
+                       key = OALLOC(&hmap->obst, entry_t);
 
                        key->q.ent   = callee;
                        key->q.pos   = i;
index 42c2be9..e6fe8b7 100644 (file)
@@ -109,7 +109,7 @@ static int is_arg(ir_node *node)
  * Allocate a new DAG entry.
  */
 static dag_entry_t *new_dag_entry(dag_env_t *dag_env, ir_node *node) {
-       dag_entry_t *entry = obstack_alloc(&dag_env->obst, sizeof(*entry));
+       dag_entry_t *entry = OALLOC(&dag_env->obst, dag_entry_t);
 
        entry->num_nodes       = 1;
        entry->num_roots       = 1;
index ea9bd25..08c358d 100644 (file)
@@ -108,7 +108,7 @@ static distrib_entry_t *distrib_get_entry(distrib_tbl_t *tbl, const void *object
        if (elem)
                return elem;
 
-       elem = obstack_alloc(&tbl->cnts, sizeof(*elem));
+       elem = OALLOC(&tbl->cnts, distrib_entry_t);
 
        /* clear counter */
        cnt_clr(&elem->cnt);
index 8582f10..e05961f 100644 (file)
@@ -226,8 +226,7 @@ static node_entry_t *opcode_get_entry(const ir_op *op, hmap_node_entry_t *hmap)
        if (elem)
                return elem;
 
-       elem = obstack_alloc(&status->cnts, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(&status->cnts, node_entry_t);
 
        /* clear counter */
        opcode_clear_entry(elem);
@@ -303,8 +302,7 @@ static graph_entry_t *graph_get_entry(ir_graph *irg, hmap_graph_entry_t *hmap)
        }  /* if */
 
        /* allocate a new one */
-       elem = obstack_alloc(&status->cnts, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(&status->cnts, graph_entry_t);
        obstack_init(&elem->recalc_cnts);
 
        /* clear counter */
@@ -349,8 +347,7 @@ static opt_entry_t *opt_get_entry(const ir_op *op, hmap_opt_entry_t *hmap)
        if (elem)
                return elem;
 
-       elem = obstack_alloc(&status->cnts, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(&status->cnts, opt_entry_t);
 
        /* clear new counter */
        opt_clear_entry(elem);
@@ -387,8 +384,7 @@ static block_entry_t *block_get_entry(struct obstack *obst, long block_nr, hmap_
        if (elem)
                return elem;
 
-       elem = obstack_alloc(obst, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(obst, block_entry_t);
 
        /* clear new counter */
        block_clear_entry(elem);
@@ -434,8 +430,7 @@ static be_block_entry_t *be_block_get_entry(struct obstack *obst, long block_nr,
        if (elem)
                return elem;
 
-       elem = obstack_alloc(obst, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(obst, be_block_entry_t);
 
        /* clear new counter */
        be_block_clear_entry(elem);
@@ -473,8 +468,7 @@ static perm_class_entry_t *perm_class_get_entry(struct obstack *obst, const char
        if (elem)
                return elem;
 
-       elem = obstack_alloc(obst, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(obst, perm_class_entry_t);
 
        /* clear new counter */
        perm_class_clear_entry(elem);
@@ -515,8 +509,7 @@ static perm_stat_entry_t *perm_stat_get_entry(struct obstack *obst, ir_node *per
        if (elem)
                return elem;
 
-       elem = obstack_alloc(obst, sizeof(*elem));
-       memset(elem, 0, sizeof(*elem));
+       elem = OALLOCZ(obst, perm_stat_entry_t);
 
        /* clear new counter */
        perm_stat_clear_entry(elem);
@@ -1973,8 +1966,7 @@ void stat_be_block_regpressure(ir_graph *irg, ir_node *block, int pressure, cons
                reg_pressure_entry_t *rp_ent;
 
                block_ent = be_block_get_entry(&status->be_data, get_irn_node_nr(block), graph->be_block_hash);
-               rp_ent    = obstack_alloc(&status->be_data, sizeof(*rp_ent));
-               memset(rp_ent, 0, sizeof(*rp_ent));
+               rp_ent    = OALLOCZ(&status->be_data, reg_pressure_entry_t);
 
                rp_ent->class_name = class_name;
                rp_ent->pressure   = pressure;
index cc7dbab..47ff364 100644 (file)
@@ -648,9 +648,7 @@ static pattern_entry_t *pattern_get_entry(CODE_BUFFER *buf, pset *set) {
        unsigned len = buf_lenght(buf);
        unsigned hash;
 
-       key = obstack_alloc(&status->obst, offsetof(pattern_entry_t, buf) + len);
-       assert(key);
-
+       key = OALLOCF(&status->obst, pattern_entry_t, buf, len);
        key->len = len;
        memcpy(key->buf, buf_content(buf), len);
 
index e98b515..0ea833f 100644 (file)
@@ -56,7 +56,7 @@ static block_entry_t *get_block_entry(ir_node *block) {
        block_entry_t *entry = get_irn_link(block);
 
        if (entry == NULL) {
-               entry = obstack_alloc(&env->obst, sizeof(*entry));
+               entry = OALLOC(&env->obst, block_entry_t);
 
                entry->live_ins  = NEW_ARR_F(ir_node *, 0);
                entry->live_outs = NEW_ARR_F(ir_node *, 0);