Skip to content

Commit 4c384d1

Browse files
committed
refactor
1 parent f4f6922 commit 4c384d1

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

crates/rustc_codegen_spirv/src/linker/inline_globals.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,19 @@ 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+
let mut has_run = false;
8384
//std::fs::write("res0.txt", module.disassemble());
8485
while cont {
8586
cont = inline_global_varaibles_rec(sess, module)?;
87+
has_run = has_run || cont;
8688
i += 1;
8789
//std::fs::write(format!("res{}.txt", i), module.disassemble());
8890
}
91+
// needed because inline global create duplicate types...
92+
if has_run {
93+
let _timer = sess.timer("link_remove_duplicate_types_round_2");
94+
super::duplicates::remove_duplicate_types(&mut module);
95+
}
8996
Ok(())
9097
}
9198

@@ -172,13 +179,15 @@ fn inline_global_varaibles_rec(sess: &Session, module: &mut Module) -> super::Re
172179
}
173180
}
174181
}
182+
// retain ones can rewrite
175183
function_args.retain(|_, k| match k {
176184
FunctionArg::Invalid => false,
177185
FunctionArg::Insts(v) => !v.is_empty(),
178186
});
179187
if function_args.is_empty() {
180188
return Ok(false);
181189
}
190+
// start rewrite
182191
for function in &mut module.functions {
183192
let def = function.def.as_mut().unwrap();
184193
let fid = def.result_id.unwrap();

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,6 @@ pub fn link(sess: &Session, mut inputs: Vec<Module>, opts: &Options) -> Result<L
230230
inline_globals::inline_global_varaibles(sess, &mut output)?;
231231
}
232232

233-
// needed because inline global create duplicate types...
234-
{
235-
let _timer = sess.timer("link_remove_duplicate_types_round_2");
236-
duplicates::remove_duplicate_types(&mut output);
237-
}
238-
239233
{
240234
let _timer = sess.timer("link_inline");
241235
inline::inline(sess, &mut output)?;

0 commit comments

Comments
 (0)