Skip to content

Commit d6d3cef

Browse files
eddybLegNeato
authored andcommitted
linker: add --dump-{pre,post}-inline to be able to debug the inliner.
1 parent 4f072f7 commit d6d3cef

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

crates/rustc_codegen_spirv/src/codegen_cx/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,18 @@ impl CodegenArgs {
442442
"dump the merged module immediately after merging, to a file in DIR",
443443
"DIR",
444444
);
445+
opts.optopt(
446+
"",
447+
"dump-pre-inline",
448+
"dump the module immediately before inlining, to a file in DIR",
449+
"DIR",
450+
);
451+
opts.optopt(
452+
"",
453+
"dump-post-inline",
454+
"dump the module immediately after inlining, to a file in DIR",
455+
"DIR",
456+
);
445457
opts.optopt(
446458
"",
447459
"dump-post-split",
@@ -620,6 +632,8 @@ impl CodegenArgs {
620632
// NOTE(eddyb) these are debugging options that used to be env vars
621633
// (for more information see `docs/src/codegen-args.md`).
622634
dump_post_merge: matches_opt_dump_dir_path("dump-post-merge"),
635+
dump_pre_inline: matches_opt_dump_dir_path("dump-pre-inline"),
636+
dump_post_inline: matches_opt_dump_dir_path("dump-post-inline"),
623637
dump_post_split: matches_opt_dump_dir_path("dump-post-split"),
624638
dump_spirt_passes: matches_opt_dump_dir_path("dump-spirt-passes"),
625639
spirt_strip_custom_debuginfo_from_dumps: matches

crates/rustc_codegen_spirv/src/linker/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ pub struct Options {
5858
// NOTE(eddyb) these are debugging options that used to be env vars
5959
// (for more information see `docs/src/codegen-args.md`).
6060
pub dump_post_merge: Option<PathBuf>,
61+
pub dump_pre_inline: Option<PathBuf>,
62+
pub dump_post_inline: Option<PathBuf>,
6163
pub dump_post_split: Option<PathBuf>,
6264
pub dump_spirt_passes: Option<PathBuf>,
6365
pub spirt_strip_custom_debuginfo_from_dumps: bool,
@@ -402,6 +404,10 @@ pub fn link(
402404
duplicates::remove_duplicate_debuginfo(&mut output);
403405
}
404406

407+
if let Some(dir) = &opts.dump_pre_inline {
408+
dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps));
409+
}
410+
405411
{
406412
let _timer = sess.timer("link_inline");
407413
inline::inline(sess, &mut output)?;
@@ -412,6 +418,11 @@ pub fn link(
412418
dce::dce(&mut output);
413419
}
414420

421+
// HACK(eddyb) this has to be after DCE, to not break SPIR-T w/ dead decorations.
422+
if let Some(dir) = &opts.dump_post_inline {
423+
dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps));
424+
}
425+
415426
{
416427
let _timer = sess.timer("link_block_ordering_pass_and_mem2reg-after-inlining");
417428
let mut pointer_to_pointee = FxHashMap::default();

docs/src/codegen-args.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ Dumps the merged module, to a file in `DIR`, immediately after merging, but befo
7979
similar to `--dump-pre-link`, except it outputs only a single file, which might make grepping through
8080
for stuff easier.
8181

82+
### `--dump-pre-inline DIR`
83+
84+
Dumps the module, to a file in `DIR`, immediately before the inliner pass runs.
85+
86+
### `--dump-post-inline DIR`
87+
88+
Dumps the module, to a file in `DIR`, immediately after the inliner pass runs.
89+
8290
### `--dump-post-split DIR`
8391

8492
Dumps the modules, to files in `DIR`, immediately after multimodule splitting, but before final cleanup passes (e.g.

0 commit comments

Comments
 (0)