Skip to content

Commit f4f6922

Browse files
committed
fix: warns
1 parent a71cfc0 commit f4f6922

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
3737
let mut dropped_ids = FxHashSet::default();
3838
module.functions.retain(|f| {
3939
if should_inline(&disallowed_argument_types, &disallowed_return_types, f) {
40+
if has_dont_inline(f) {
41+
sess.warn(&format!(
42+
"Function `{}` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types",
43+
get_name(&get_names(module), f.def_id().unwrap())
44+
));
45+
}
4046
// TODO: We should insert all defined IDs in this function.
4147
dropped_ids.insert(f.def_id().unwrap());
4248
false
@@ -202,23 +208,28 @@ fn compute_disallowed_argument_and_return_types(
202208
(disallowed_argument_types, disallowed_return_types)
203209
}
204210

211+
fn has_dont_inline(
212+
function: &Function,
213+
) -> bool {
214+
let def = function.def.as_ref().unwrap();
215+
let control = def.operands[0].unwrap_function_control();
216+
control.contains(FunctionControl::DONT_INLINE)
217+
}
218+
219+
205220
fn should_inline(
206221
disallowed_argument_types: &FxHashSet<Word>,
207222
disallowed_return_types: &FxHashSet<Word>,
208223
function: &Function,
209224
) -> bool {
210225
let def = function.def.as_ref().unwrap();
211226
let control = def.operands[0].unwrap_function_control();
212-
let should = control.contains(FunctionControl::INLINE)
227+
control.contains(FunctionControl::INLINE)
213228
|| function
214229
.parameters
215230
.iter()
216231
.any(|inst| disallowed_argument_types.contains(inst.result_type.as_ref().unwrap()))
217-
|| disallowed_return_types.contains(&function.def.as_ref().unwrap().result_type.unwrap());
218-
// if should && control.contains(FunctionControl::DONT_INLINE) {
219-
// println!("should not be inlined!");
220-
// }
221-
should
232+
|| disallowed_return_types.contains(&function.def.as_ref().unwrap().result_type.unwrap())
222233
}
223234

224235
// This should be more general, but a very common problem is passing an OpAccessChain to an

crates/rustc_codegen_spirv/src/linker/inline_globals.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ enum FunctionArg {
8080
pub fn inline_global_varaibles(sess: &Session, module: &mut Module) -> super::Result<()> {
8181
let mut i = 0;
8282
let mut cont = true;
83-
std::fs::write("res0.txt", module.disassemble());
83+
//std::fs::write("res0.txt", module.disassemble());
8484
while cont {
8585
cont = inline_global_varaibles_rec(sess, module)?;
8686
i += 1;
87-
std::fs::write(format!("res{}.txt", i), module.disassemble());
87+
//std::fs::write(format!("res{}.txt", i), module.disassemble());
8888
}
8989
Ok(())
9090
}

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L
321321
let _timer = sess.timer("link_sort_globals");
322322
simple_passes::sort_globals(&mut output);
323323
}
324-
325-
// std::fs::write("res.txt", output.disassemble());
326324

327325
let mut output = if opts.emit_multiple_modules {
328326
let modules = output

0 commit comments

Comments
 (0)