diff options
author | Magnus Lång <[email protected]> | 2016-09-01 17:21:25 +0200 |
---|---|---|
committer | Magnus Lång <[email protected]> | 2016-09-05 19:16:26 +0200 |
commit | 1039c0196a7e643c63ce71b2c6daa2b78b3aa832 (patch) | |
tree | 7540338826d46f9850278b3af8ad84e2f4c76119 /lib/hipe/x86/hipe_x86_ra.erl | |
parent | b4695b8088b8fc6f3844e33246849ed8bb8b18cf (diff) | |
download | otp-1039c0196a7e643c63ce71b2c6daa2b78b3aa832.tar.gz otp-1039c0196a7e643c63ce71b2c6daa2b78b3aa832.tar.bz2 otp-1039c0196a7e643c63ce71b2c6daa2b78b3aa832.zip |
hipe: Reuse liveness between regalloc iterations
This is sound because the liveness data structure only stores liveness
info at basic block boundaries, and the rewrites that happen in
TargetSpecific:check_and_rewrite/2 preserves all existing definitions
and uses, and all new liveness intervals, belonging to newly introduced
temporaries, are always local to a basic block, and thus do not show up
in the liveout or livein sets for the basic block.
Diffstat (limited to 'lib/hipe/x86/hipe_x86_ra.erl')
-rw-r--r-- | lib/hipe/x86/hipe_x86_ra.erl | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/lib/hipe/x86/hipe_x86_ra.erl b/lib/hipe/x86/hipe_x86_ra.erl index 3af333ab4b..1a860bebb1 100644 --- a/lib/hipe/x86/hipe_x86_ra.erl +++ b/lib/hipe/x86/hipe_x86_ra.erl @@ -49,27 +49,24 @@ code_size(CFG) -> ra(CFG0, Options) -> %% hipe_x86_cfg:pp(CFG0), - {CFG1, Coloring_fp, SpillIndex, Liveness} = - case ra_fp(CFG0, Options) of - {G, C, I} -> {G, C, I, undefined}; - {_,_,_,_}=T -> T - end, + Liveness0 = ?HIPE_X86_SPECIFIC:analyze(CFG0), + {CFG1, Liveness, Coloring_fp, SpillIndex} = ra_fp(CFG0, Liveness0, Options), %% hipe_x86_cfg:pp(CFG1), ?start_ra_instrumentation(Options, code_size(CFG1), element(2,hipe_gensym:var_range(x86))), - {CFG2, Coloring} + {CFG2, _, Coloring} = case proplists:get_value(regalloc, Options, coalescing) of coalescing -> - ra(CFG1, SpillIndex, Options, hipe_coalescing_regalloc); + ra(CFG1, Liveness, SpillIndex, Options, hipe_coalescing_regalloc); optimistic -> - ra(CFG1, SpillIndex, Options, hipe_optimistic_regalloc); + ra(CFG1, Liveness, SpillIndex, Options, hipe_optimistic_regalloc); graph_color -> - ra(CFG1, SpillIndex, Options, hipe_graph_coloring_regalloc); + ra(CFG1, Liveness, SpillIndex, Options, hipe_graph_coloring_regalloc); linear_scan -> ?HIPE_X86_RA_LS:ra(CFG1, Liveness, SpillIndex, Options); naive -> - ?HIPE_X86_RA_NAIVE:ra(CFG1, Coloring_fp, Options); + ?HIPE_X86_RA_NAIVE:ra(CFG1, Liveness, Coloring_fp, Options); _ -> exit({unknown_regalloc_compiler_option, proplists:get_value(regalloc,Options)}) @@ -80,11 +77,12 @@ ra(CFG0, Options) -> %% hipe_x86_cfg:pp(CFG2), ?HIPE_X86_RA_FINALISE:finalise(CFG2, Coloring, Coloring_fp, Options). -ra(CFG, SpillIndex, Options, RegAllocMod) -> - hipe_regalloc_loop:ra(CFG, SpillIndex, Options, RegAllocMod, ?HIPE_X86_SPECIFIC). +ra(CFG, Liveness, SpillIndex, Options, RegAllocMod) -> + hipe_regalloc_loop:ra(CFG, Liveness, SpillIndex, Options, RegAllocMod, + ?HIPE_X86_SPECIFIC). -ifdef(HIPE_AMD64). -ra_fp(CFG, Options) -> +ra_fp(CFG, Liveness, Options) -> Regalloc0 = proplists:get_value(regalloc, Options), {Regalloc, TargetMod} = case proplists:get_bool(inline_fp, Options) and (Regalloc0 =/= naive) of @@ -96,25 +94,27 @@ ra_fp(CFG, Options) -> end end, case Regalloc of - coalescing -> ra_fp(CFG, Options, hipe_coalescing_regalloc, TargetMod); - optimistic -> ra_fp(CFG, Options, hipe_optimistic_regalloc, TargetMod); - graph_color -> ra_fp(CFG, Options, hipe_graph_coloring_regalloc, - TargetMod); - linear_scan -> hipe_amd64_ra_ls:ra_fp(CFG, Options, TargetMod); - naive -> {CFG,[],0}; + coalescing -> + ra_fp(CFG, Liveness, Options, hipe_coalescing_regalloc, TargetMod); + optimistic -> + ra_fp(CFG, Liveness, Options, hipe_optimistic_regalloc, TargetMod); + graph_color -> + ra_fp(CFG, Liveness, Options, hipe_graph_coloring_regalloc, TargetMod); + linear_scan -> hipe_amd64_ra_ls:ra_fp(CFG, Liveness, Options, TargetMod); + naive -> {CFG,Liveness,[],0}; _ -> exit({unknown_regalloc_compiler_option, proplists:get_value(regalloc,Options)}) end. -ra_fp(CFG, Options, RegAllocMod, TargetMod) -> - hipe_regalloc_loop:ra_fp(CFG, Options, RegAllocMod, TargetMod). +ra_fp(CFG, Liveness, Options, RegAllocMod, TargetMod) -> + hipe_regalloc_loop:ra_fp(CFG, Liveness, Options, RegAllocMod, TargetMod). -else. -ra_fp(CFG, Options) -> +ra_fp(CFG, Liveness, Options) -> case proplists:get_bool(inline_fp, Options) of true -> - hipe_x86_ra_ls:ra_fp(CFG, Options, hipe_x86_specific_x87); + hipe_x86_ra_ls:ra_fp(CFG, Liveness, Options, hipe_x86_specific_x87); false -> - {CFG,[],0} + {CFG,Liveness,[],0} end. -endif. |