Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hercules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
Hercules
Commits
4572a7ec
Commit
4572a7ec
authored
1 month ago
by
Russel Arbore
Browse files
Options
Downloads
Patches
Plain Diff
Inline constants
parent
b336327e
No related branches found
No related tags found
1 merge request
!202
Round 1 of rodinia schedule optimization
Pipeline
#201897
passed
1 month ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
hercules_opt/src/editor.rs
+12
-0
12 additions, 0 deletions
hercules_opt/src/editor.rs
hercules_opt/src/inline.rs
+108
-18
108 additions, 18 deletions
hercules_opt/src/inline.rs
juno_samples/rodinia/bfs/src/cpu.sch
+1
-0
1 addition, 0 deletions
juno_samples/rodinia/bfs/src/cpu.sch
with
121 additions
and
18 deletions
hercules_opt/src/editor.rs
+
12
−
0
View file @
4572a7ec
...
...
@@ -880,6 +880,18 @@ impl<'a, 'b> FunctionEdit<'a, 'b> {
}
}
pub
fn
get_param_types
(
&
self
)
->
&
Vec
<
TypeID
>
{
self
.updated_param_types
.as_ref
()
.unwrap_or
(
&
self
.editor.function.param_types
)
}
pub
fn
get_return_types
(
&
self
)
->
&
Vec
<
TypeID
>
{
self
.updated_return_types
.as_ref
()
.unwrap_or
(
&
self
.editor.function.return_types
)
}
pub
fn
set_param_types
(
&
mut
self
,
tys
:
Vec
<
TypeID
>
)
{
self
.updated_param_types
=
Some
(
tys
);
}
...
...
This diff is collapsed.
Click to expand it.
hercules_opt/src/inline.rs
+
108
−
18
View file @
4572a7ec
...
...
@@ -235,7 +235,7 @@ fn inline_func(
}
}
#[derive(Clone,
Debug,
Copy)]
#[derive(Clone,
Debug,
Copy
,
PartialEq,
Eq
)]
enum
ParameterLattice
{
Top
,
Constant
(
ConstantID
),
...
...
@@ -331,6 +331,7 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
// constant) to this function.
let
mut
param_lattice
=
vec!
[
ParameterLattice
::
Top
;
func
.param_types
.len
()];
let
mut
dc_param_lattice
=
vec!
[
ParameterLattice
::
Top
;
func
.num_dynamic_constants
as
usize
];
let
mut
callers
=
vec!
[];
for
caller
in
callgraph
.get_callers
(
func_id
)
{
let
editor
=
&
editors
[
caller
.idx
()];
let
nodes
=
&
editor
.func
()
.nodes
;
...
...
@@ -338,28 +339,117 @@ pub fn const_inline(editors: &mut [FunctionEditor], callgraph: &CallGraph) {
if
let
Some
((
_
,
callee
,
dc_args
,
args
))
=
nodes
[
id
.idx
()]
.try_call
()
&&
callee
==
func_id
{
for
(
idx
,
id
)
in
args
.into_iter
()
.enumerate
()
{
let
lattice
=
ParameterLattice
::
from_node
(
&
nodes
[
id
.idx
()],
callee
);
param_lattice
[
idx
]
.meet
(
lattice
,
editor
.get_constants
(),
editor
.get_dynamic_constants
(),
);
if
editor
.is_mutable
(
id
)
{
for
(
idx
,
id
)
in
args
.into_iter
()
.enumerate
()
{
let
lattice
=
ParameterLattice
::
from_node
(
&
nodes
[
id
.idx
()],
callee
);
param_lattice
[
idx
]
.meet
(
lattice
,
editor
.get_constants
(),
editor
.get_dynamic_constants
(),
);
}
for
(
idx
,
id
)
in
dc_args
.into_iter
()
.enumerate
()
{
let
lattice
=
ParameterLattice
::
DynamicConstant
(
*
id
,
func_id
);
dc_param_lattice
[
idx
]
.meet
(
lattice
,
editor
.get_constants
(),
editor
.get_dynamic_constants
(),
);
}
}
else
{
// If we can't modify the call node in the caller, then
// we can't perform the inlining.
param_lattice
=
vec!
[
ParameterLattice
::
Bottom
;
func
.param_types
.len
()];
dc_param_lattice
=
vec!
[
ParameterLattice
::
Bottom
;
func
.num_dynamic_constants
as
usize
];
}
callers
.push
((
caller
,
id
));
}
}
}
if
param_lattice
.iter
()
.all
(|
v
|
*
v
==
ParameterLattice
::
Bottom
)
&&
dc_param_lattice
.iter
()
.all
(|
v
|
*
v
==
ParameterLattice
::
Bottom
)
{
continue
;
}
for
(
idx
,
id
)
in
dc_args
.into_iter
()
.enumerate
()
{
let
lattice
=
ParameterLattice
::
DynamicConstant
(
*
id
,
func_id
);
dc_param_lattice
[
idx
]
.meet
(
lattice
,
editor
.get_constants
(),
editor
.get_dynamic_constants
(),
);
// Replace the arguments.
let
editor
=
&
mut
editors
[
func_id
.idx
()];
let
mut
param_idx_to_ids
:
HashMap
<
usize
,
Vec
<
NodeID
>>
=
HashMap
::
new
();
for
id
in
editor
.node_ids
()
{
if
let
Some
(
idx
)
=
editor
.func
()
.nodes
[
id
.idx
()]
.try_parameter
()
{
param_idx_to_ids
.entry
(
idx
)
.or_default
()
.push
(
id
);
}
}
let
mut
params_to_remove
=
vec!
[];
let
success
=
editor
.edit
(|
mut
edit
|
{
let
mut
param_tys
=
edit
.get_param_types
()
.clone
();
let
mut
decrement_index_by
=
0
;
for
idx
in
0
..
param_tys
.len
()
{
if
let
Some
(
node
)
=
match
param_lattice
[
idx
]
{
ParameterLattice
::
Top
=>
Some
(
Node
::
Undef
{
ty
:
param_tys
[
idx
]
}),
ParameterLattice
::
Constant
(
id
)
=>
Some
(
Node
::
Constant
{
id
}),
_
=>
None
,
}
&&
let
Some
(
ids
)
=
param_idx_to_ids
.get
(
&
idx
)
{
let
node
=
edit
.add_node
(
node
);
for
id
in
ids
{
edit
=
edit
.replace_all_uses
(
*
id
,
node
)
?
;
edit
=
edit
.delete_node
(
*
id
)
?
;
}
param_tys
.remove
(
idx
-
decrement_index_by
);
params_to_remove
.push
(
idx
);
decrement_index_by
+=
1
;
}
else
if
decrement_index_by
!=
0
&&
let
Some
(
ids
)
=
param_idx_to_ids
.get
(
&
idx
)
{
let
node
=
edit
.add_node
(
Node
::
Parameter
{
index
:
idx
-
decrement_index_by
,
});
for
id
in
ids
{
edit
=
edit
.replace_all_uses
(
*
id
,
node
)
?
;
edit
=
edit
.delete_node
(
*
id
)
?
;
}
}
}
edit
.set_param_types
(
param_tys
);
Ok
(
edit
)
});
params_to_remove
.reverse
();
// Update callers.
if
success
{
for
(
caller
,
call
)
in
callers
{
let
editor
=
&
mut
editors
[
caller
.idx
()];
let
success
=
editor
.edit
(|
mut
edit
|
{
let
Node
::
Call
{
control
,
function
,
dynamic_constants
,
args
,
}
=
edit
.get_node
(
call
)
.clone
()
else
{
panic!
();
};
let
mut
args
=
args
.into_vec
();
for
idx
in
params_to_remove
.iter
()
{
args
.remove
(
*
idx
);
}
let
node
=
edit
.add_node
(
Node
::
Call
{
control
,
function
,
dynamic_constants
,
args
:
args
.into_boxed_slice
(),
});
edit
=
edit
.replace_all_uses
(
call
,
node
)
?
;
edit
=
edit
.delete_node
(
call
)
?
;
Ok
(
edit
)
});
assert!
(
success
);
}
}
println!
(
"{}:"
,
func
.name
);
println!
(
"{:?}"
,
param_lattice
);
println!
(
"{:?}"
,
dc_param_lattice
);
}
}
This diff is collapsed.
Click to expand it.
juno_samples/rodinia/bfs/src/cpu.sch
+
1
−
0
View file @
4572a7ec
...
...
@@ -23,5 +23,6 @@ fixpoint {
fork-coalesce(*);
}
const-inline(*);
simpl!(*);
gcm(*);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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