Skip to content

Commit 99f25a6

Browse files
committed
linker/inline: reuse information about which functions should be inlined.
The functions we are going to delete definitely either need to be inlined, or are never called (so we don't care what to decide about them).
1 parent 37e659d commit 99f25a6

File tree

1 file changed

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

1 file changed

+11
-17
lines changed

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
5858
void,
5959
ptr_map,
6060
functions: &functions,
61-
disallowed_argument_types: &disallowed_argument_types,
62-
disallowed_return_types: &disallowed_return_types,
61+
needs_inline: &to_delete,
6362
};
6463
for index in postorder {
6564
inliner.inline_fn(&mut module.functions, index);
@@ -297,9 +296,7 @@ struct Inliner<'m, 'map> {
297296
void: Word,
298297
ptr_map: FxHashMap<Word, Word>,
299298
functions: &'map FunctionMap,
300-
disallowed_argument_types: &'map FxHashSet<Word>,
301-
disallowed_return_types: &'map FxHashSet<Word>,
302-
// rewrite_rules: FxHashMap<Word, Word>,
299+
needs_inline: &'map [bool],
303300
}
304301

305302
impl Inliner<'_, '_> {
@@ -356,23 +353,20 @@ impl Inliner<'_, '_> {
356353
.enumerate()
357354
.filter(|(_, inst)| inst.class.opcode == Op::FunctionCall)
358355
.map(|(index, inst)| {
359-
let idx = self
360-
.functions
361-
.get(&inst.operands[0].id_ref_any().unwrap())
362-
.unwrap();
363-
(index, inst, &functions[*idx])
356+
(
357+
index,
358+
inst,
359+
self.functions[&inst.operands[0].id_ref_any().unwrap()],
360+
)
364361
})
365-
.find(|(_, inst, f)| {
366-
should_inline(
367-
self.disallowed_argument_types,
368-
self.disallowed_return_types,
369-
f,
370-
) || args_invalid(caller, inst)
362+
.find(|(index, inst, func_idx)| {
363+
self.needs_inline[*func_idx] || args_invalid(caller, inst)
371364
});
372-
let (call_index, call_inst, callee) = match call {
365+
let (call_index, call_inst, callee_idx) = match call {
373366
None => return false,
374367
Some(call) => call,
375368
};
369+
let callee = &functions[callee_idx];
376370
let call_result_type = {
377371
let ty = call_inst.result_type.unwrap();
378372
if ty == self.void {

0 commit comments

Comments
 (0)