Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/rustc_codegen_spirv/src/linker/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
// Drop all the functions we'll be inlining. (This also means we won't waste time processing
// inlines in functions that will get inlined)
let mut dropped_ids = FxHashSet::default();
let mut inlined_dont_inlines = Vec::new();
module.functions.retain(|f| {
if should_inline(&disallowed_argument_types, &disallowed_return_types, f) {
if has_dont_inline(f) {
inlined_dont_inlines.push(f.def_id().unwrap());
}
// TODO: We should insert all defined IDs in this function.
dropped_ids.insert(f.def_id().unwrap());
false
} else {
true
}
});
if !inlined_dont_inlines.is_empty() {
let names = get_names(module);
for f in inlined_dont_inlines {
sess.warn(&format!(
"function `{}` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types",
get_name(&names, f)
));
}
}

// Drop OpName etc. for inlined functions
module.debug_names.retain(|inst| {
!inst.operands.iter().any(|op| {
Expand Down Expand Up @@ -204,6 +218,12 @@ fn compute_disallowed_argument_and_return_types(
(disallowed_argument_types, disallowed_return_types)
}

fn has_dont_inline(function: &Function) -> bool {
let def = function.def.as_ref().unwrap();
let control = def.operands[0].unwrap_function_control();
control.contains(FunctionControl::DONT_INLINE)
}

fn should_inline(
disallowed_argument_types: &FxHashSet<Word>,
disallowed_return_types: &FxHashSet<Word>,
Expand Down
Loading