Skip to content

Commit 2ac82f0

Browse files
committed
linker/inline: also run remove_duplicate_debuginfo on every fully-inlined function.
1 parent 6c5895f commit 2ac82f0

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

crates/rustc_codegen_spirv/src/linker/duplicates.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,20 @@ pub fn remove_duplicate_debuginfo(module: &mut Module) {
283283
})
284284
.map(|inst| inst.result_id.unwrap());
285285

286+
let deduper = DebuginfoDeduplicator {
287+
custom_ext_inst_set_import,
288+
};
286289
for func in &mut module.functions {
290+
deduper.remove_duplicate_debuginfo_in_function(func)
291+
}
292+
}
293+
294+
pub struct DebuginfoDeduplicator {
295+
pub custom_ext_inst_set_import: Option<Word>,
296+
}
297+
298+
impl DebuginfoDeduplicator {
299+
pub fn remove_duplicate_debuginfo_in_function(&self, func: &mut rspirv::dr::Function) {
287300
for block in &mut func.blocks {
288301
// Ignore the terminator, it's effectively "outside" debuginfo.
289302
let (_, insts) = block.instructions.split_last_mut().unwrap();
@@ -339,7 +352,8 @@ pub fn remove_duplicate_debuginfo(module: &mut Module) {
339352
let inst = &insts[inst_idx];
340353
let custom_op = match inst.class.opcode {
341354
Op::ExtInst
342-
if Some(inst.operands[0].unwrap_id_ref()) == custom_ext_inst_set_import =>
355+
if Some(inst.operands[0].unwrap_id_ref())
356+
== self.custom_ext_inst_set_import =>
343357
{
344358
Some(CustomOp::decode_from_ext_inst(inst))
345359
}

crates/rustc_codegen_spirv/src/linker/inline.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ pub fn inline(sess: &Session, module: &mut Module) -> super::Result<()> {
139139
let mut function = mem::replace(&mut functions[func_idx], Err(FuncIsBeingInlined)).unwrap();
140140
inliner.inline_fn(&mut function, &functions);
141141
fuse_trivial_branches(&mut function);
142+
143+
super::duplicates::DebuginfoDeduplicator {
144+
custom_ext_inst_set_import,
145+
}.remove_duplicate_debuginfo_in_function(&mut function);
146+
142147
functions[func_idx] = Ok(function);
143148
}
144149

0 commit comments

Comments
 (0)