Skip to content

Commit 4bf2f9b

Browse files
committed
fixes
1 parent df3d40c commit 4bf2f9b

File tree

8 files changed

+23
-53
lines changed

8 files changed

+23
-53
lines changed

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
3535
// Drop all the functions we'll be inlining. (This also means we won't waste time processing
3636
// inlines in functions that will get inlined)
3737
let mut dropped_ids = FxHashSet::default();
38+
let mut inlined_dont_inlines = Vec::new();
3839
module.functions.retain(|f| {
3940
if should_inline(&disallowed_argument_types, &disallowed_return_types, f) {
4041
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-
));
42+
inlined_dont_inlines.push(f.def_id().unwrap());
4543
}
4644
// TODO: We should insert all defined IDs in this function.
4745
dropped_ids.insert(f.def_id().unwrap());
@@ -50,6 +48,16 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
5048
true
5149
}
5250
});
51+
if !inlined_dont_inlines.is_empty() {
52+
let names = get_names(module);
53+
for f in inlined_dont_inlines {
54+
sess.warn(&format!(
55+
"Function `{}` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types",
56+
get_name(&names, f)
57+
));
58+
}
59+
}
60+
5361
// Drop OpName etc. for inlined functions
5462
module.debug_names.retain(|inst| {
5563
!inst.operands.iter().any(|op| {
@@ -208,15 +216,12 @@ fn compute_disallowed_argument_and_return_types(
208216
(disallowed_argument_types, disallowed_return_types)
209217
}
210218

211-
fn has_dont_inline(
212-
function: &Function,
213-
) -> bool {
219+
fn has_dont_inline(function: &Function) -> bool {
214220
let def = function.def.as_ref().unwrap();
215221
let control = def.operands[0].unwrap_function_control();
216222
control.contains(FunctionControl::DONT_INLINE)
217223
}
218224

219-
220225
fn should_inline(
221226
disallowed_argument_types: &FxHashSet<Word>,
222227
disallowed_return_types: &FxHashSet<Word>,

crates/rustc_codegen_spirv/src/linker/inline_globals.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use rspirv::binary::Disassemble;
21
use rspirv::dr::{Instruction, Module, Operand};
3-
use rspirv::spirv::{Op, StorageClass};
2+
use rspirv::spirv::{Op};
43
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
54
use rustc_session::Session;
65

@@ -83,20 +82,20 @@ pub fn inline_global_varaibles(sess: &Session, module: &mut Module) -> super::Re
8382
let mut has_run = false;
8483
//std::fs::write("res0.txt", module.disassemble());
8584
while cont {
86-
cont = inline_global_varaibles_rec(sess, module)?;
85+
cont = inline_global_varaibles_rec(module)?;
8786
has_run = has_run || cont;
8887
i += 1;
8988
//std::fs::write(format!("res{}.txt", i), module.disassemble());
9089
}
9190
// needed because inline global create duplicate types...
9291
if has_run {
9392
let _timer = sess.timer("link_remove_duplicate_types_round_2");
94-
super::duplicates::remove_duplicate_types(&mut module);
93+
super::duplicates::remove_duplicate_types(module);
9594
}
9695
Ok(())
9796
}
9897

99-
fn inline_global_varaibles_rec(sess: &Session, module: &mut Module) -> super::Result<bool> {
98+
fn inline_global_varaibles_rec(module: &mut Module) -> super::Result<bool> {
10099
// first collect global stuff
101100
let mut variables: FxHashSet<u32> = FxHashSet::default();
102101
let mut function_types: FxHashMap<u32, Instruction> = FxHashMap::default();

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,6 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L
218218
);
219219
}
220220

221-
// this is needed so we can inline more global variables
222-
// {
223-
// let _timer = sess.timer("simpl_op_store_var");
224-
// simpl_op_store_var::simpl_op_store_var(sess, &mut output)?;
225-
// }
226-
227221
{
228222
let _timer = sess.timer("link_inline_global");
229223
inline_globals::inline_global_varaibles(sess, &mut output)?;

tests/ui/dis/index_user_dst.stderr

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
11
%1 = OpFunction %2 None %3
22
%4 = OpLabel
3-
OpLine %5 7 12
4-
%6 = OpAccessChain %7 %8 %9
5-
%10 = OpArrayLength %11 %8 0
6-
OpLine %5 8 21
7-
%12 = OpULessThan %13 %9 %10
8-
OpLine %5 8 21
9-
OpSelectionMerge %14 None
10-
OpBranchConditional %12 %15 %16
11-
%15 = OpLabel
12-
OpLine %5 8 21
13-
%17 = OpInBoundsAccessChain %18 %6 %9
14-
%19 = OpLoad %20 %17
15-
OpLine %5 10 1
3+
OpLine %5 7 0
4+
%6 = OpFunctionCall %2 %7
165
OpReturn
17-
%16 = OpLabel
18-
OpLine %5 8 21
19-
OpBranch %21
20-
%21 = OpLabel
21-
OpBranch %22
22-
%22 = OpLabel
23-
%23 = OpPhi %13 %24 %21 %24 %25
24-
OpLoopMerge %26 %25 None
25-
OpBranchConditional %23 %27 %26
26-
%27 = OpLabel
27-
OpBranch %25
28-
%25 = OpLabel
29-
OpBranch %22
30-
%26 = OpLabel
31-
OpUnreachable
32-
%14 = OpLabel
33-
OpUnreachable
346
OpFunctionEnd

tests/ui/dis/ptr_read.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
OpLine %8 1096 8
66
%9 = OpLoad %10 %4
77
OpLine %11 7 13
8-
OpStore %6 %9
8+
OpStore %6 %12
99
OpLine %11 8 1
1010
OpReturn
1111
OpFunctionEnd

tests/ui/dis/ptr_read_method.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
OpLine %8 1096 8
66
%9 = OpLoad %10 %4
77
OpLine %11 7 13
8-
OpStore %6 %9
8+
OpStore %6 %12
99
OpLine %11 8 1
1010
OpReturn
1111
OpFunctionEnd
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
warning: function `nested_ref::deep_load` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types
1+
warning: Function `nested_ref::deep_load` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types
22

3-
warning: function `nested_ref::deep_transpose` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types
3+
warning: Function `nested_ref::deep_transpose` has `dont_inline` attribute, but need to be inlined because it has illegal argument or return types
44

55
warning: 2 warnings emitted
66

File renamed without changes.

0 commit comments

Comments
 (0)