5 # script_i_prepare was run before this
7 analyze_reach_defs(cfg
)
8 # Need to do before DCE and even before insert_initial_regs
9 collect_reach_exit(cfg
)
10 collect_reach_exit_maybe(cfg
)
12 # analyze_live_vars uses modifieds, so if preserveds is available, we need
13 # to update modifieds for possible update in reach_exit, otherwise we'll
14 # have positive feedback in propagation and bad flip-flop effect for preserveds
16 if "preserveds" in cfg
.props
:
17 modifieds
= cfg
.props
["reach_exit"] - cfg
.props
["preserveds"]
18 progdb
.update_cfg_prop(cfg
, "modifieds", modifieds
)
20 analyze_live_vars(cfg
)
21 insert_initial_regs(cfg
)
23 analyze_reach_defs(cfg
)
25 #const_propagation(cfg)
26 #copy_propagation(cfg)
28 # May infinite-loop without $sp_0, etc.
31 # To rewrite stack vars, we need to propagate $sp_0, hence all the above
32 foreach_inst(cfg
, rewrite_stack_vars
, rewrite_to
=REG
)
34 # Now need to do second propagation phase, of stack vars
35 analyze_reach_defs(cfg
)
38 # Analyze and record preserved registers
39 collect_preserveds(cfg
)
41 modifieds
= cfg
.props
["reach_exit"] - cfg
.props
["preserveds"]
42 progdb
.update_cfg_prop(cfg
, "modifieds", modifieds
)
45 # Argument estimation part
48 # Reanalyze live vars for DCE
49 analyze_live_vars(cfg
)
50 # Eliminate any preservation assignments, and thus liveness of preserved regs
51 foreach_bblock(cfg
, dead_code_elimination
)