Compilation: add verbose_air_output for programmatic Air capture
Add a verbose_air_output field to Compilation that redirects verbose Air dumps to a caller-provided writer instead of stderr. When set, liveness is omitted from the output to support textual comparison in stage0 tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -165,6 +165,7 @@ clang_preprocessor_mode: ClangPreprocessorMode,
|
||||
/// Whether to print clang argvs to stdout.
|
||||
verbose_cc: bool,
|
||||
verbose_air: bool,
|
||||
verbose_air_output: ?*std.io.Writer = null,
|
||||
verbose_intern_pool: bool,
|
||||
verbose_generic_instances: bool,
|
||||
verbose_llvm_ir: ?[]const u8,
|
||||
@@ -2259,6 +2260,7 @@ pub fn create(gpa: Allocator, arena: Allocator, diag: *CreateDiagnostic, options
|
||||
.clang_preprocessor_mode = options.clang_preprocessor_mode,
|
||||
.verbose_cc = options.verbose_cc,
|
||||
.verbose_air = options.verbose_air,
|
||||
.verbose_air_output = null,
|
||||
.verbose_intern_pool = options.verbose_intern_pool,
|
||||
.verbose_generic_instances = options.verbose_generic_instances,
|
||||
.verbose_llvm_ir = options.verbose_llvm_ir,
|
||||
|
||||
@@ -4468,11 +4468,17 @@ fn runCodegenInner(pt: Zcu.PerThread, func_index: InternPool.Index, air: *Air) e
|
||||
defer if (liveness) |*l| l.deinit(gpa);
|
||||
|
||||
if (build_options.enable_debug_extensions and comp.verbose_air) {
|
||||
const stderr = std.debug.lockStderrWriter(&.{});
|
||||
defer std.debug.unlockStderrWriter();
|
||||
stderr.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}) catch {};
|
||||
air.write(stderr, pt, liveness);
|
||||
stderr.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}) catch {};
|
||||
if (comp.verbose_air_output) |writer| {
|
||||
writer.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}) catch {};
|
||||
air.write(writer, pt, null);
|
||||
writer.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}) catch {};
|
||||
} else {
|
||||
const stderr = std.debug.lockStderrWriter(&.{});
|
||||
defer std.debug.unlockStderrWriter();
|
||||
stderr.print("# Begin Function AIR: {f}:\n", .{fqn.fmt(ip)}) catch {};
|
||||
air.write(stderr, pt, liveness);
|
||||
stderr.print("# End Function AIR: {f}\n\n", .{fqn.fmt(ip)}) catch {};
|
||||
}
|
||||
}
|
||||
|
||||
if (std.debug.runtime_safety) verify_liveness: {
|
||||
|
||||
Reference in New Issue
Block a user