Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker: speedup and debug info preservation #21

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
14 changes: 14 additions & 0 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,18 @@ impl CodegenArgs {
"dump the merged module immediately after merging, to a file in DIR",
"DIR",
);
opts.optopt(
"",
"dump-pre-inline",
"dump the module immediately before inlining, to a file in DIR",
"DIR",
);
opts.optopt(
"",
"dump-post-inline",
"dump the module immediately after inlining, to a file in DIR",
"DIR",
);
opts.optopt(
"",
"dump-post-split",
Expand Down Expand Up @@ -628,6 +640,8 @@ impl CodegenArgs {
// NOTE(eddyb) these are debugging options that used to be env vars
// (for more information see `docs/src/codegen-args.md`).
dump_post_merge: matches_opt_dump_dir_path("dump-post-merge"),
dump_pre_inline: matches_opt_dump_dir_path("dump-pre-inline"),
dump_post_inline: matches_opt_dump_dir_path("dump-post-inline"),
dump_post_split: matches_opt_dump_dir_path("dump-post-split"),
dump_spirt_passes: matches_opt_dump_dir_path("dump-spirt-passes"),
spirt_strip_custom_debuginfo_from_dumps: matches
Expand Down
11 changes: 6 additions & 5 deletions crates/rustc_codegen_spirv/src/linker/dce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
//! *references* a rooted thing is also rooted, not the other way around - but that's the basic
//! concept.

use rspirv::dr::{Function, Instruction, Module, Operand};
use rspirv::dr::{Block, Function, Instruction, Module, Operand};
use rspirv::spirv::{Decoration, LinkageType, Op, StorageClass, Word};
use rustc_data_structures::fx::FxIndexSet;
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use std::hash::Hash;

pub fn dce(module: &mut Module) {
let mut rooted = collect_roots(module);
Expand Down Expand Up @@ -137,11 +138,11 @@ fn kill_unrooted(module: &mut Module, rooted: &FxIndexSet<Word>) {
}
}

pub fn dce_phi(func: &mut Function) {
pub fn dce_phi(blocks: &mut FxIndexMap<impl Eq + Hash, &mut Block>) {
let mut used = FxIndexSet::default();
loop {
let mut changed = false;
for inst in func.all_inst_iter() {
for inst in blocks.values().flat_map(|block| &block.instructions) {
if inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()) {
for op in &inst.operands {
if let Some(id) = op.id_ref_any() {
Expand All @@ -154,7 +155,7 @@ pub fn dce_phi(func: &mut Function) {
break;
}
}
for block in &mut func.blocks {
for block in blocks.values_mut() {
block
.instructions
.retain(|inst| inst.class.opcode != Op::Phi || used.contains(&inst.result_id.unwrap()));
Expand Down
Loading