Skip to content

Commit 5c1cdb9

Browse files
eddybFirestar99
authored andcommitted
linker: add --dump-{pre,post}-inline to be able to debug the inliner.
1 parent 7dfa257 commit 5c1cdb9

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
@@ -438,6 +438,18 @@ impl CodegenArgs {
438438
"dump the merged module immediately after merging, to a file in DIR",
439439
"DIR",
440440
);
441+
opts.optopt(
442+
"",
443+
"dump-pre-inline",
444+
"dump the module immediately before inlining, to a file in DIR",
445+
"DIR",
446+
);
447+
opts.optopt(
448+
"",
449+
"dump-post-inline",
450+
"dump the module immediately after inlining, to a file in DIR",
451+
"DIR",
452+
);
441453
opts.optopt(
442454
"",
443455
"dump-post-split",
@@ -628,6 +640,8 @@ impl CodegenArgs {
628640
// NOTE(eddyb) these are debugging options that used to be env vars
629641
// (for more information see `docs/src/codegen-args.md`).
630642
dump_post_merge: matches_opt_dump_dir_path("dump-post-merge"),
643+
dump_pre_inline: matches_opt_dump_dir_path("dump-pre-inline"),
644+
dump_post_inline: matches_opt_dump_dir_path("dump-post-inline"),
631645
dump_post_split: matches_opt_dump_dir_path("dump-post-split"),
632646
dump_spirt_passes: matches_opt_dump_dir_path("dump-spirt-passes"),
633647
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,
@@ -416,6 +418,10 @@ pub fn link(
416418
duplicates::remove_duplicate_debuginfo(&mut output);
417419
}
418420

421+
if let Some(dir) = &opts.dump_pre_inline {
422+
dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps));
423+
}
424+
419425
{
420426
let _timer = sess.timer("link_inline");
421427
inline::inline(sess, &mut output)?;
@@ -426,6 +432,11 @@ pub fn link(
426432
dce::dce(&mut output);
427433
}
428434

435+
// HACK(eddyb) this has to be after DCE, to not break SPIR-T w/ dead decorations.
436+
if let Some(dir) = &opts.dump_post_inline {
437+
dump_spv_and_spirt(&output, dir.join(disambiguated_crate_name_for_dumps));
438+
}
439+
429440
{
430441
let _timer = sess.timer("link_block_ordering_pass_and_mem2reg-after-inlining");
431442
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)