Skip to content

Commit a57d8e0

Browse files
committed
linker/inline: fix test regression
Just inlining entry points deletes functions from tests and makes everyone sad.
1 parent 5065da2 commit a57d8e0

File tree

1 file changed

+5
-17
lines changed
  • crates/rustc_codegen_spirv/src/linker

1 file changed

+5
-17
lines changed

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ type FunctionMap = FxHashMap<Word, usize>;
1818
pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
1919
let (disallowed_argument_types, disallowed_return_types) =
2020
compute_disallowed_argument_and_return_types(module);
21-
let mut to_delete: Vec<_> = module
21+
let to_delete: Vec<_> = module
2222
.functions
2323
.iter()
2424
.map(|f| should_inline(&disallowed_argument_types, &disallowed_return_types, f))
2525
.collect();
2626
// This algorithm gets real sad if there's recursion - but, good news, SPIR-V bans recursion
27-
let postorder = compute_function_postorder(sess, module, &mut to_delete)?;
27+
let postorder = compute_function_postorder(sess, module, &to_delete)?;
2828
let functions = module
2929
.functions
3030
.iter()
@@ -76,7 +76,7 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
7676
fn compute_function_postorder(
7777
sess: &Session,
7878
module: &Module,
79-
to_delete: &mut [bool],
79+
to_delete: &[bool],
8080
) -> super::Result<Vec<usize>> {
8181
let func_to_index: FxHashMap<Word, usize> = module
8282
.functions
@@ -93,18 +93,12 @@ fn compute_function_postorder(
9393
Discovered,
9494
/// DFS returned.
9595
Finished,
96-
/// Not visited, entry point.
97-
Entry,
9896
}
9997
let mut states = vec![NodeState::NotVisited; module.functions.len()];
100-
for opep in module.entry_points.iter() {
101-
let func_id = opep.operands[1].unwrap_id_ref();
102-
states[func_to_index[&func_id]] = NodeState::Entry;
103-
}
10498
let mut has_recursion = false;
10599
let mut postorder = vec![];
106100
for index in 0..module.functions.len() {
107-
if NodeState::Entry == states[index] {
101+
if NodeState::NotVisited == states[index] && !to_delete[index] {
108102
visit(
109103
sess,
110104
module,
@@ -117,12 +111,6 @@ fn compute_function_postorder(
117111
}
118112
}
119113

120-
for index in 0..module.functions.len() {
121-
if NodeState::NotVisited == states[index] {
122-
to_delete[index] = true;
123-
}
124-
}
125-
126114
fn visit(
127115
sess: &Session,
128116
module: &Module,
@@ -148,7 +136,7 @@ fn compute_function_postorder(
148136
*has_recursion = true;
149137
break;
150138
}
151-
NodeState::NotVisited | NodeState::Entry => {
139+
NodeState::NotVisited => {
152140
visit(
153141
sess,
154142
module,

0 commit comments

Comments
 (0)