Adding ValueStore printing and --dump-shared-values (#3320)

This replaces the printing that was removed from SemIR's raw dump. It's
separate because (for example) lexing generates shared values, and so
reviewing them is not specific to any particular phase.
This commit is contained in:
Jon Ross-Perkins
2023-10-20 21:31:50 +00:00
committed by GitHub
parent 5b3b7aa3ed
commit 843dd40f22
3 changed files with 65 additions and 4 deletions
+15 -1
View File
@@ -180,6 +180,14 @@ and displaying them in source order.
},
[&](auto& arg_b) { arg_b.Set(&stream_errors); });
b.AddFlag(
{
.name = "dump-shared-values",
.help = R"""(
Dumps shared values. These aren't owned by any particular file or phase.
)""",
},
[&](auto& arg_b) { arg_b.Set(&dump_shared_values); });
b.AddFlag(
{
.name = "dump-tokens",
@@ -257,6 +265,7 @@ Dump the generated assembly to stdout after codegen.
bool asm_output = false;
bool force_obj_output = false;
bool dump_shared_values = false;
bool dump_tokens = false;
bool dump_parse_tree = false;
bool dump_raw_sem_ir = false;
@@ -599,7 +608,6 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
return false;
}
SharedValueStores value_stores;
llvm::SmallVector<std::unique_ptr<CompilationUnit>> units;
auto flush = llvm::make_scope_exit([&]() {
// The diagnostics consumer must be flushed before compilation artifacts are
@@ -609,6 +617,12 @@ auto Driver::Compile(const CompileOptions& options) -> bool {
unit->Flush();
}
});
SharedValueStores value_stores;
auto dump_shared_values = llvm::make_scope_exit([&]() {
if (options.dump_shared_values) {
output_stream_ << value_stores;
}
});
for (const auto& input_file_name : options.input_file_names) {
units.push_back(std::make_unique<CompilationUnit>(
this, &value_stores, options, input_file_name));