Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
c740a32e
Commit
c740a32e
authored
May 22, 2015
by
yb9976
Browse files
Properly reserve and free link resource.
parent
621e1ef4
Changes
19
Hide whitespace changes
Inline
Side-by-side
ir/ana/cgana.c
View file @
c740a32e
...
...
@@ -646,7 +646,9 @@ static void callee_ana(void)
/* analyse all graphs */
foreach_irp_irg
(
i
,
irg
)
{
assure_irg_properties
(
irg
,
IR_GRAPH_PROPERTY_NO_TUPLES
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
callee_walker
,
NULL
,
NULL
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
set_irg_callee_info_state
(
irg
,
irg_callee_info_consistent
);
}
set_irp_callee_info_state
(
irg_callee_info_consistent
);
...
...
ir/ana/ircfscc.c
View file @
c740a32e
...
...
@@ -590,6 +590,8 @@ void construct_cf_backedges(ir_graph *irg)
struct
obstack
temp
;
obstack_init
(
&
temp
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
init_scc
(
irg
,
&
temp
);
current_loop
=
NULL
;
...
...
@@ -610,6 +612,7 @@ void construct_cf_backedges(ir_graph *irg)
cfscc
(
el
);
}
finish_scc
();
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
obstack_free
(
&
temp
,
NULL
);
assert
(
head_rem
==
current_loop
);
...
...
ir/be/amd64/amd64_emitter.c
View file @
c740a32e
...
...
@@ -903,6 +903,7 @@ void amd64_emit_function(ir_graph *irg)
be_gas_emit_function_prolog
(
entity
,
4
,
NULL
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_block_walk_graph
(
irg
,
amd64_gen_labels
,
NULL
,
NULL
);
n
=
ARR_LEN
(
blk_sched
);
...
...
@@ -918,6 +919,7 @@ void amd64_emit_function(ir_graph *irg)
amd64_gen_block
(
block
,
0
);
}
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
be_gas_emit_function_epilog
(
entity
);
}
ir/be/arm/arm_emitter.c
View file @
c740a32e
...
...
@@ -773,6 +773,7 @@ void arm_emit_function(ir_graph *irg)
parameter_dbg_info_t
*
const
infos
=
construct_parameter_infos
(
irg
);
be_gas_emit_function_prolog
(
entity
,
4
,
infos
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_block_walk_graph
(
irg
,
arm_gen_labels
,
NULL
,
NULL
);
ir_node
*
last_block
=
NULL
;
...
...
@@ -785,6 +786,7 @@ void arm_emit_function(ir_graph *irg)
arm_gen_block
(
block
,
last_block
);
last_block
=
block
;
}
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* emit entity and tarval values */
if
(
ent_or_tv_first
!=
NULL
)
{
...
...
ir/be/beblocksched.c
View file @
c740a32e
...
...
@@ -563,6 +563,7 @@ ir_node **be_create_block_schedule(ir_graph *irg)
assure_loopinfo
(
irg
);
// collect edge execution frequencies
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_block_walk_graph
(
irg
,
collect_egde_frequency
,
NULL
,
&
env
);
remove_empty_blocks
(
irg
);
...
...
@@ -570,6 +571,7 @@ ir_node **be_create_block_schedule(ir_graph *irg)
coalesce_blocks
(
&
env
);
ir_node
**
const
block_list
=
create_blocksched_array
(
&
env
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
DEL_ARR_F
(
env
.
edges
);
obstack_free
(
&
env
.
obst
,
NULL
);
...
...
ir/be/beprefalloc.c
View file @
c740a32e
...
...
@@ -1672,6 +1672,7 @@ static void determine_block_order(void)
size_t
order_p
=
0
;
/* clear block links... */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
for
(
size_t
p
=
0
;
p
<
n_blocks
;
++
p
)
{
ir_node
*
block
=
blocklist
[
p
];
set_irn_link
(
block
,
NULL
);
...
...
@@ -1749,7 +1750,7 @@ static void determine_block_order(void)
assert
(
order_p
==
n_blocks
);
del_pdeq
(
worklist
);
ir_free_resources
(
irg
,
IR_RESOURCE_BLOCK_VISITED
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
|
IR_RESOURCE_BLOCK_VISITED
);
DEL_ARR_F
(
blocklist
);
...
...
ir/be/bespillbelady.c
View file @
c740a32e
...
...
@@ -840,12 +840,11 @@ static void be_spill_belady(ir_graph *irg, const arch_register_class_t *rcls)
assure_loopinfo
(
irg
);
stat_ev_tim_pop
(
"belady_time_backedges"
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
stat_ev_tim_push
();
irg_walk_graph
(
irg
,
firm_clear_link
,
NULL
,
NULL
);
stat_ev_tim_pop
(
"belady_time_clear_links"
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* init belady env */
stat_ev_tim_push
();
obstack_init
(
&
obst
);
...
...
ir/be/bestate.c
View file @
c740a32e
...
...
@@ -415,6 +415,7 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env,
assure_irg_properties
(
irg
,
IR_GRAPH_PROPERTY_CONSISTENT_LOOPINFO
|
IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
);
be_assure_live_sets
(
irg
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_VISITED
|
IR_RESOURCE_IRN_LINK
);
minibelady_env_t
env
;
obstack_init
(
&
env
.
obst
);
...
...
@@ -427,7 +428,6 @@ void be_assure_state(ir_graph *irg, const arch_register_t *reg, void *func_env,
env
.
spills
=
NULL
;
ir_nodehashmap_init
(
&
env
.
spill_infos
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_VISITED
|
IR_RESOURCE_IRN_LINK
);
inc_irg_visited
(
irg
);
/* process blocks */
...
...
ir/be/betranshlp.c
View file @
c740a32e
...
...
@@ -312,7 +312,9 @@ void be_transform_graph(ir_graph *irg, arch_pretrans_nodes *func)
new_identities
(
irg
);
/* do the main transformation */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
transform_nodes
(
irg
,
func
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* free the old obstack */
obstack_free
(
&
old_obst
,
0
);
...
...
ir/be/sparc/sparc_emitter.c
View file @
c740a32e
...
...
@@ -1464,6 +1464,7 @@ void sparc_emit_function(ir_graph *irg)
ir_node
**
block_schedule
=
be_create_block_schedule
(
irg
);
sparc_emit_func_prolog
(
irg
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_block_walk_graph
(
irg
,
init_jump_links
,
NULL
,
NULL
);
/* inject block scheduling links & emit code of each block */
...
...
@@ -1475,6 +1476,7 @@ void sparc_emit_function(ir_graph *irg)
}
pick_delay_slots
(
n_blocks
,
block_schedule
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
for
(
size_t
i
=
0
;
i
<
n_blocks
;
++
i
)
{
ir_node
*
block
=
block_schedule
[
i
];
...
...
ir/ir/irgopt.c
View file @
c740a32e
...
...
@@ -52,7 +52,9 @@ void local_optimize_node(ir_node *n)
new_identities
(
irg
);
/* walk over the graph */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk
(
n
,
firm_clear_link
,
optimize_in_place_wrapper
,
NULL
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
}
static
void
enqueue_node
(
ir_node
*
node
,
pdeq
*
waitq
)
...
...
@@ -215,5 +217,7 @@ void local_opts_const_code(void)
/* Clean the value_table in irg for the CSE. */
new_identities
(
irg
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
walk_const_code
(
firm_clear_link
,
optimize_in_place_wrapper
,
NULL
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
}
ir/lower/lower_calls.c
View file @
c740a32e
...
...
@@ -900,6 +900,7 @@ static void transform_irg(compound_call_lowering_flags flags, ir_graph *irg)
env
.
only_local_mem
=
true
;
/* scan the code, fix argument numbers and collect calls. */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
firm_clear_link
,
NULL
,
&
env
);
irg_walk_graph
(
irg
,
fix_args_and_collect_calls
,
NULL
,
&
env
);
...
...
@@ -918,6 +919,7 @@ static void transform_irg(compound_call_lowering_flags flags, ir_graph *irg)
remove_compound_param_entities
(
irg
);
fix_calls
(
&
env
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* transform return nodes */
if
(
n_ret_com
>
0
)
{
...
...
ir/opt/dead_code_elimination.c
View file @
c740a32e
...
...
@@ -97,7 +97,9 @@ void dead_node_elimination(ir_graph *irg)
new_identities
(
irg
);
/* Copy the graph from the old to the new obstack */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
copy_graph_env
(
irg
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* Free memory from old unoptimized obstack */
obstack_free
(
&
graveyard_obst
,
0
);
/* First empty the obstack ... */
...
...
ir/opt/ldstopt.c
View file @
c740a32e
...
...
@@ -2278,6 +2278,7 @@ void optimize_load_store(ir_graph *irg)
obstack_init
(
&
env
.
obst
);
/* init the links, then collect Loads/Stores/Proj's in lists */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
master_visited
=
0
;
irg_walk_graph
(
irg
,
firm_clear_link
,
collect_nodes
,
&
env
);
...
...
@@ -2291,6 +2292,7 @@ void optimize_load_store(ir_graph *irg)
irg_walk_graph
(
irg
,
NULL
,
do_eliminate_dead_stores
,
&
env
);
env
.
changes
|=
optimize_loops
(
irg
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
obstack_free
(
&
env
.
obst
,
NULL
);
...
...
ir/opt/opt_inline.c
View file @
c740a32e
...
...
@@ -1194,9 +1194,12 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
phiproj_computed
=
true
;
collect_phiprojs_and_start_block_nodes
(
current_ir_graph
);
}
ir_reserve_resources
(
callee
,
IR_RESOURCE_IRN_LINK
);
bool
did_inline
=
inline_method
(
curr_call
->
call
,
callee
);
if
(
!
did_inline
)
if
(
!
did_inline
)
{
ir_free_resources
(
callee
,
IR_RESOURCE_IRN_LINK
);
continue
;
}
/* call was inlined, Phi/Projs for current graph must be recomputed */
phiproj_computed
=
false
;
...
...
@@ -1235,6 +1238,7 @@ static void inline_into(ir_graph *irg, unsigned maxsize,
list_add_tail
(
&
new_entry
->
list
,
&
env
->
calls
);
maybe_push_call
(
pqueue
,
new_entry
,
inline_threshold
);
}
ir_free_resources
(
callee
,
IR_RESOURCE_IRN_LINK
);
env
->
n_call_nodes
+=
callee_env
->
n_call_nodes
;
env
->
n_nodes
+=
callee_env
->
n_nodes
;
...
...
ir/opt/opt_osr.c
View file @
c740a32e
...
...
@@ -1214,13 +1214,13 @@ void remove_phi_cycles(ir_graph *irg)
* the same block as their predecessors.
* This can improve the placement of new nodes.
*/
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
NULL
,
firm_clear_link
,
NULL
);
/* calculate the post order number for blocks. */
irg_out_block_walk
(
get_irg_start_block
(
irg
),
NULL
,
assign_po
,
&
env
);
/* calculate the SCC's and drive OSR. */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
do_dfs
(
irg
,
&
env
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
...
...
@@ -1331,12 +1331,12 @@ void opt_osr(ir_graph *irg, unsigned flags)
* the same block as its predecessors.
* This can improve the placement of new nodes.
*/
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
NULL
,
firm_clear_link
,
NULL
);
irg_block_edges_walk
(
get_irg_start_block
(
irg
),
NULL
,
assign_po
,
&
env
);
/* calculate the SCC's and drive OSR. */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
do_dfs
(
irg
,
&
env
);
if
(
env
.
replaced
)
{
...
...
ir/opt/parallelize_mem.c
View file @
c740a32e
...
...
@@ -499,6 +499,8 @@ void opt_parallelize_mem(ir_graph *irg)
assure_irg_properties
(
irg
,
IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES
|
IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE
);
irg_walk_blkwise_dom_top_down
(
irg
,
NULL
,
walker
,
NULL
);
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
eliminate_sync_edges
(
irg
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
confirm_irg_properties
(
irg
,
IR_GRAPH_PROPERTIES_CONTROL_FLOW
);
}
ir/opt/reassoc.c
View file @
c740a32e
...
...
@@ -2030,6 +2030,7 @@ static void do_chaining(ir_graph *irg)
waitq
*
const
wq
=
new_waitq
();
/* now we have collected enough information, optimize */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
NULL
,
wq_walker
,
wq
);
while
(
!
waitq_empty
(
wq
))
{
...
...
@@ -2063,6 +2064,7 @@ static void do_chaining(ir_graph *irg)
}
}
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
del_waitq
(
wq
);
}
...
...
@@ -2094,8 +2096,10 @@ void optimize_reassociation(ir_graph *irg)
waitq
*
const
wq
=
new_waitq
();
/* now we have collected enough information, optimize */
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
irg_walk_graph
(
irg
,
NULL
,
wq_walker
,
wq
);
do_reassociation
(
wq
);
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* reverse those rules that do not result in collapsed constants */
irg_walk_graph
(
irg
,
NULL
,
reverse_rules
,
NULL
);
...
...
ir/opt/return.c
View file @
c740a32e
...
...
@@ -211,6 +211,8 @@ void normalize_n_returns(ir_graph *irg)
ir_node
*
endbl
=
get_irg_end_block
(
irg
);
ir_node
*
final
=
NULL
;
ir_node
*
list
=
NULL
;
ir_reserve_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
for
(
int
i
=
0
,
n
=
get_Block_n_cfgpreds
(
endbl
);
i
<
n
;
++
i
)
{
ir_node
*
ret
=
get_Block_cfgpred
(
endbl
,
i
);
...
...
@@ -231,6 +233,7 @@ void normalize_n_returns(ir_graph *irg)
}
if
(
n_rets
==
0
)
{
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
confirm_irg_properties
(
irg
,
IR_GRAPH_PROPERTIES_ALL
);
add_irg_properties
(
irg
,
IR_GRAPH_PROPERTY_MANY_RETURNS
);
return
;
...
...
@@ -313,6 +316,7 @@ void normalize_n_returns(ir_graph *irg)
}
exchange
(
endbl
,
new_r_Block
(
irg
,
n_finals
,
endbl_in
));
ir_free_resources
(
irg
,
IR_RESOURCE_IRN_LINK
);
/* Invalidate analysis information:
* Blocks become dead and new Returns were deleted, so dominator, outs and
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment