Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
CompilerHIT
Compiler2023
Commits
a2f0fdc2
Commit
a2f0fdc2
authored
1 year ago
by
cncsmonster
Browse files
Options
Download
Patches
Plain Diff
增加运行时检查
parent
a19ca236
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backend/regalloc/perfect_alloc.rs
+9
-4
src/backend/regalloc/perfect_alloc.rs
with
9 additions
and
4 deletions
+9
-4
src/backend/regalloc/perfect_alloc.rs
+
9
−
4
View file @
a2f0fdc2
...
...
@@ -75,6 +75,7 @@ pub fn build_live_neighbors_from_all_neigbhors(
for
(
_
,
lns
)
in
live_neighbors
.iter_mut
()
{
lns
.retain
(|
reg
|
!
reg
.is_physic
());
}
check_if_full_neighbors
(
&
live_neighbors
);
live_neighbors
}
...
...
@@ -102,6 +103,7 @@ pub fn fill_live_neighbors_to_all_neighbors_with_availables(
}
}
live_neighbors
.extend
(
p_nbs
);
check_if_full_neighbors
(
&
live_neighbors
);
}
///根据活邻居图构建全图
...
...
@@ -129,20 +131,23 @@ pub fn build_live_neighbors_to_all_neighbors_with_availables(
}
}
live_neighbors
.extend
(
p_nbs
);
check_if_full_neighbors
(
&
live_neighbors
);
live_neighbors
}
///检查是否是完整的图 ,两个节点间有双向边
#[inline]
pub
fn
check_if_full_neighbors
(
all_neighbors
:
&
HashMap
<
Reg
,
HashSet
<
Reg
>>
)
{
debug_assert!
({
debug_assert!
(
||
->
bool
{
for
(
r
,
nbs
)
in
all_neighbors
.iter
()
{
for
nb
in
nbs
.iter
()
{
assert!
(
all_neighbors
.get
(
nb
)
.unwrap
()
.contains
(
r
));
if
!
all_neighbors
.get
(
nb
)
.unwrap
()
.contains
(
r
)
{
return
false
;
}
}
}
true
});
}
()
);
}
///化简活邻接图,获取最后消去序列
...
...
@@ -289,7 +294,7 @@ pub fn alloc_with_live_neighbors_and_availables(
let
base_live_neighbors
=
live_neighbors
.clone
();
let
mut
last_to_colors
=
LinkedList
::
new
();
let
mut
pre_colors
:
HashMap
<
Reg
,
i32
>
=
HashMap
::
new
();
//
如果仍然无法完美优化,试探是否有某种着色不影响邻居可着色性的着色个例进行优化
//
迭代化简图,直到化简结束
loop
{
let
tmp_last_tocolors
=
simplify_live_graph_and_build_last_tocolors
(
live_neighbors
,
&
availables
);
...
...
This diff is collapsed.
Click to expand it.
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!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets