mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:10:12 +01:00
Add a feature to explicitly include a file's SemIR (#5961)
Trying to figure out an easy way to debug semir in the prelude, #5703 removed an option to set `--exclude-dump-file-prefix` to empty. But, this is probably an improvement over that flow... With this change, it's possible to add `//@dump-sem-ir-file` to a specific prelude file, and its full IR will be printed. Additionally, it becomes an option with the default `--dump-sem-ir-ranges=only` to add `//@dump-sem-ir-file` and get the full file's IR.
This commit is contained in:
@@ -29,6 +29,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
- [Verbose output](#verbose-output)
|
||||
- [Stack traces](#stack-traces)
|
||||
- [Dumping objects in interactive debuggers](#dumping-objects-in-interactive-debuggers)
|
||||
- [Dumping prelude files](#dumping-prelude-files)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
@@ -539,8 +540,10 @@ automatically included as well. A small amount of SemIR may include a number of
|
||||
related instructions, such as an in-range instruction referencing an import_ref
|
||||
referencing a constant referencing another constant.
|
||||
|
||||
> NOTE: In a test, if full SemIR is desired for files, add
|
||||
> `// EXTRA-ARGS: --dump-sem-ir-ranges=if-present` with an explanation why.
|
||||
SemIR dumps for files that don't have explicit ranges can be enabled through
|
||||
either `//@include-in-dumps` (per-file) or
|
||||
`// EXTRA-ARGS: --dump-sem-ir-ranges=if-present`. These should be rare, and are
|
||||
worth comments when they're used.
|
||||
|
||||
##### Example uses
|
||||
|
||||
@@ -634,3 +637,13 @@ regarding support.
|
||||
|
||||
Objects which inherit from `Printable` also have `Dump` member functions, but
|
||||
these will lack contextual information.
|
||||
|
||||
#### Dumping prelude files
|
||||
|
||||
By default, prelude files are excluded from dumps by
|
||||
`--exclude-dump-file-prefix`. To enable dumps for specific files, add
|
||||
`//@include-in-dumps`. This works for every phase after lex, but may be most
|
||||
helpful to debug check and lower output. This can also be used to view
|
||||
cross-file SemIR, such as imports from a prelude, by adding
|
||||
`//@include-in-dumps` to the prelude file and looking at the SemIR of the
|
||||
importing file.
|
||||
|
||||
Reference in New Issue
Block a user