Skip to content

Commit

Permalink
Support all TracingModes in CLI args
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Dec 26, 2023
1 parent ac1e1b3 commit 12d3551
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 41 additions & 18 deletions compiler/cli/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,47 @@ pub struct PathAndExecutionTargetAndTracing {
#[arg(long, value_enum, default_value_t = ExecutionTargetKind::Module)]
execution_target: ExecutionTargetKind,

#[arg(long)]
register_fuzzables: bool,

#[arg(long)]
trace_calls: bool,

#[arg(long)]
trace_evaluated_expressions: bool,
// The tracing modes can be specified as follows:
//
// - not specified or `--register-fuzzables=off`: off
// - `--register-fuzzables` of `--register-fuzzables=only-current`: only current
// - `--register-fuzzables=all`: all
//
// (Same for `trace-calls` and `evaluated-expressions`.)
#[arg(
long,
default_value("off"),
default_missing_value("only-current"),
num_args(0..=1),
require_equals(true)
)]
register_fuzzables: TracingMode,

#[arg(
long,
default_value("off"),
default_missing_value("only-current"),
num_args(0..=1),
require_equals(true)
)]
trace_calls: TracingMode,

#[arg(
long,
default_value("off"),
default_missing_value("only-current"),
num_args(0..=1),
require_equals(true)
)]
trace_evaluated_expressions: TracingMode,
}
impl PathAndExecutionTargetAndTracing {
#[must_use]
const fn to_tracing_config(&self) -> TracingConfig {
TracingConfig {
register_fuzzables: TracingMode::only_current_or_off(self.register_fuzzables),
calls: TracingMode::only_current_or_off(self.trace_calls),
evaluated_expressions: TracingMode::only_current_or_off(
self.trace_evaluated_expressions,
),
register_fuzzables: self.register_fuzzables,
calls: self.trace_calls,
evaluated_expressions: self.trace_evaluated_expressions,
}
}
}
Expand Down Expand Up @@ -380,33 +403,33 @@ impl GoldOptions {
visit("HIR", hir.text);

let (mir, _) = db
.mir(execution_target.clone(), Self::TRACING_CONFIG.clone())
.mir(execution_target.clone(), Self::TRACING_CONFIG)
.unwrap();
let mir = RichIr::for_mir(&module, &mir, Self::TRACING_CONFIG);
visit("MIR", mir.text);

let (optimized_mir, _, _) = db
.optimized_mir(execution_target.clone(), Self::TRACING_CONFIG.clone())
.optimized_mir(execution_target.clone(), Self::TRACING_CONFIG)
.unwrap();
let optimized_mir =
RichIr::for_optimized_mir(&module, &optimized_mir, Self::TRACING_CONFIG);
visit("Optimized MIR", optimized_mir.text);

let (lir, _) = db
.lir(execution_target.clone(), Self::TRACING_CONFIG.clone())
.lir(execution_target.clone(), Self::TRACING_CONFIG)
.unwrap();
let lir = RichIr::for_lir(&module, &lir, Self::TRACING_CONFIG);
visit("LIR", lir.text);

let (optimized_lir, _) = db
.optimized_lir(execution_target.clone(), Self::TRACING_CONFIG.clone())
.optimized_lir(execution_target.clone(), Self::TRACING_CONFIG)
.unwrap();
let optimized_lir =
RichIr::for_optimized_lir(&module, &optimized_lir, Self::TRACING_CONFIG);
visit("Optimized LIR", optimized_lir.text);

let (vm_byte_code, _) =
compile_byte_code(db, execution_target.clone(), Self::TRACING_CONFIG.clone());
compile_byte_code(db, execution_target.clone(), Self::TRACING_CONFIG);
let vm_byte_code_rich_ir =
RichIr::for_byte_code(&module, &vm_byte_code, Self::TRACING_CONFIG);
visit(
Expand Down
1 change: 1 addition & 0 deletions compiler/frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ rust-version = "1.56"
[lib]

[dependencies]
clap = { version = "4.1.8", features = ["derive"] }
derive_more = "0.99.17"
dunce = "1.0.4"
enumset = "1.0.12"
Expand Down
3 changes: 2 additions & 1 deletion compiler/frontend/src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::ValueEnum;
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -27,7 +28,7 @@ impl TracingConfig {
}
}

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, Serialize, Deserialize, ValueEnum)]
#[serde(rename_all = "camelCase")]
pub enum TracingMode {
Off,
Expand Down

1 comment on commit 12d3551

@jwbot
Copy link
Collaborator

@jwbot jwbot commented on 12d3551 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compiler

Benchmark suite Current: 12d3551 Previous: d36e515 Ratio
Time: Compiler/hello_world 18484181 ns/iter (± 526915) 17369168 ns/iter (± 355109) 1.06
Time: Compiler/fibonacci 143613651 ns/iter (± 916249) 137159030 ns/iter (± 1001993) 1.05
Time: VM Runtime/hello_world 32967 ns/iter (± 2684) 32486 ns/iter (± 49450) 1.01

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.