Skip to content

Commit b360321

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

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
@@ -19,13 +19,13 @@ type FunctionMap = FxHashMap<Word, usize>;
1919
pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
2020
let (disallowed_argument_types, disallowed_return_types) =
2121
compute_disallowed_argument_and_return_types(module);
22-
let mut to_delete: Vec<_> = module
22+
let to_delete: Vec<_> = module
2323
.functions
2424
.iter()
2525
.map(|f| should_inline(&disallowed_argument_types, &disallowed_return_types, f))
2626
.collect();
2727
// This algorithm gets real sad if there's recursion - but, good news, SPIR-V bans recursion
28-
let postorder = compute_function_postorder(sess, module, &mut to_delete)?;
28+
let postorder = compute_function_postorder(sess, module, &to_delete)?;
2929
let functions = module
3030
.functions
3131
.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 = None;
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,
@@ -147,7 +135,7 @@ fn compute_function_postorder(
147135
)));
148136
break;
149137
}
150-
NodeState::NotVisited | NodeState::Entry => {
138+
NodeState::NotVisited => {
151139
visit(
152140
sess,
153141
module,

0 commit comments

Comments
 (0)