Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-fast
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
40
Issues
40
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mu
mu-impl-fast
Commits
e0b055f7
Commit
e0b055f7
authored
Oct 18, 2017
by
qinsoon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a freeze heuristics that prioritize freezing less frequenly used
nodes
parent
a25abd66
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
2 deletions
+28
-2
coloring.rs
src/compiler/backend/reg_alloc/graph_coloring/coloring.rs
+28
-2
No files found.
src/compiler/backend/reg_alloc/graph_coloring/coloring.rs
View file @
e0b055f7
...
...
@@ -835,14 +835,40 @@ impl<'a> GraphColoring<'a> {
fn
freeze
(
&
mut
self
)
{
// it is not empty (checked before)
let
node
=
self
.
worklist_freeze
.pop_front
()
.unwrap
();
let
node
=
self
.
freeze_heuristics
();
trace!
(
"Freezing {}..."
,
node
);
trace!
(
" insert {} to worklistSimplify"
,
node
);
trace!
(
" move {} from worklistFreeze to worklistSimplify"
,
node
);
self
.worklist_freeze
.remove
(
&
node
);
self
.worklist_simplify
.insert
(
node
);
self
.freeze_moves
(
node
);
}
fn
freeze_heuristics
(
&
mut
self
)
->
MuID
{
use
std
::
f32
;
// we try to freeze a node that appears less frequently
// we compute freeze cost based on all the moves related with this node
let
mut
candidate
=
None
;
let
mut
candidate_cost
=
f32
::
MAX
;
for
&
n
in
self
.worklist_freeze
.iter
()
{
// freeze_cost(n) = SUM ((spill_cost(src) + spill_cost(dst)) for m (mov src->dst)
// in movelist[n])
let
mut
freeze_cost
=
0f32
;
for
m
in
self
.get_movelist
(
n
)
.iter
()
{
freeze_cost
+=
self
.ig
.get_spill_cost
(
m
.from
);
freeze_cost
+=
self
.ig
.get_spill_cost
(
m
.to
);
}
if
freeze_cost
<
candidate_cost
{
candidate
=
Some
(
n
);
candidate_cost
=
freeze_cost
;
}
}
assert
!
(
candidate
.is_some
());
candidate
.unwrap
()
}
fn
freeze_moves
(
&
mut
self
,
u
:
MuID
)
{
trace!
(
" freeze moves for {}"
,
u
);
for
m
in
self
.node_moves
(
u
)
.iter
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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