diff --git a/Cargo.lock b/Cargo.lock index 81f83f8071..cb1b0ee082 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,55 @@ dependencies = [ "libc", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" version = "1.0.57" @@ -112,42 +161,45 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.18" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2dbdf4bdacb33466e854ce889eee8dfd5729abf7ccd7664d0a2d60cd384440b" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ - "atty", - "bitflags", + "clap_builder", "clap_derive", + "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +dependencies = [ + "anstream", + "anstyle", "clap_lex", - "indexmap", - "lazy_static", + "once_cell", "strsim", - "termcolor", - "textwrap", ] [[package]] name = "clap_derive" -version = "3.1.18" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.95", + "syn", ] [[package]] name = "clap_lex" -version = "0.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213" -dependencies = [ - "os_str_bytes", -] +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "codespan-reporting" @@ -159,6 +211,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "colored" version = "2.0.0" @@ -213,7 +271,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.15", + "syn", ] [[package]] @@ -230,7 +288,7 @@ checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn", ] [[package]] @@ -261,6 +319,8 @@ dependencies = [ "lazy_static", "log", "nom", + "num-derive", + "num-traits", "ordermap", "petgraph", "pretty", @@ -449,9 +509,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" @@ -549,6 +609,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi 0.3.1", + "io-lifetimes", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "itoa" version = "1.0.2" @@ -653,6 +725,17 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "num-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e6a0fd4f737c707bd9086cc16c925f294943eb62eb71499e9fd4cf71f8b9f4e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -699,12 +782,6 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" -[[package]] -name = "os_str_bytes" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" - [[package]] name = "parking_lot" version = "0.12.1" @@ -777,30 +854,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.95", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" version = "1.0.56" @@ -949,7 +1002,7 @@ checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn", ] [[package]] @@ -994,7 +1047,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn", ] [[package]] @@ -1037,17 +1090,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "syn" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.15" @@ -1081,12 +1123,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "textwrap" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" - [[package]] name = "thread_local" version = "1.1.7" @@ -1191,10 +1227,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" [[package]] -name = "version_check" -version = "0.9.4" +name = "utf8parse" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "wasi" @@ -1223,7 +1259,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.15", + "syn", "wasm-bindgen-shared", ] @@ -1245,7 +1281,7 @@ checksum = "4783ce29f09b9d93134d41297aded3a712b7b979e9c6f28c32cb88c973a94869" dependencies = [ "proc-macro2", "quote", - "syn 2.0.15", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] diff --git a/Cargo.toml b/Cargo.toml index a9620db27d..8f5d8baf60 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ flowistry = { git = "https://github.com/brownsys/flowistry", rev = "f3b27bb1e06a rustc_utils = "=0.6.0-nightly-2023-04-12" rustc_plugin = "=0.6.0-nightly-2023-04-12" -clap = { version = "3", features = ["derive", "cargo", "env"] } +clap = { version = "4", features = ["derive", "cargo", "env"] } serde = { version = "1", features = ["derive"] } lazy_static = "1" ordermap = "0.3" @@ -30,7 +30,8 @@ nom = "7" log = "0.4" simple_logger = "2" petgraph = "0.6" - +num-derive = "0.4" +num-traits = "0.2" humantime = "2" indicatif = "0.17" diff --git a/src/ana/inline.rs b/src/ana/inline.rs index dbc594c6b7..55b107719e 100644 --- a/src/ana/inline.rs +++ b/src/ana/inline.rs @@ -36,7 +36,7 @@ use crate::{ body_name_pls, dump_file_pls, time, write_sep, DisplayViaDebug, IntoDefId, IntoLocalDefId, Print, RecursionBreakingCache, TinyBitSet, }, - AnalysisCtrl, DbgArgs, Either, HashMap, HashSet, Symbol, TyCtxt, + AnalysisCtrl, DumpArgs, Either, HashMap, HashSet, Symbol, TyCtxt, }; use super::df::MarkerCarryingOracle; @@ -487,7 +487,7 @@ pub struct Inliner<'tcx, 'g, 's> { tcx: TyCtxt<'tcx>, gli: GLI<'g>, ana_ctrl: &'static AnalysisCtrl, - dbg_ctrl: &'static DbgArgs, + dbg_ctrl: &'static DumpArgs, marker_carrying: MarkerCarryingOracle<'tcx, 's>, } @@ -653,7 +653,7 @@ impl<'tcx, 'g, 's> Inliner<'tcx, 'g, 's> { gli: GLI<'g>, recurse_selector: &'s (dyn Oracle + 's), ana_ctrl: &'static AnalysisCtrl, - dbg_ctrl: &'static DbgArgs, + dbg_ctrl: &'static DumpArgs, ) -> Self { Self { tcx, diff --git a/src/args.rs b/src/args.rs index 1e22dc81b1..754b01bed1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -11,9 +11,68 @@ use std::{borrow::Cow, str::FromStr}; +use clap::ValueEnum; + +use crate::utils::TinyBitSet; + +use crate::{num_derive, num_traits::FromPrimitive}; + +#[derive(serde::Deserialize, serde::Serialize)] +pub struct Args(GArgs); + +#[derive(clap::Args)] +pub struct ParseableArgs { + #[clap(flatten)] + ignored: GArgs, +} + +impl Args { + pub fn from_parseable(value: ParseableArgs) -> Result { + let ParseableArgs { + ignored: + GArgs { + verbose, + debug, + debug_target, + result_path, + relaxed, + target, + abort_after_analysis, + anactrl, + modelctrl, + dump, + }, + } = value; + let mut dump: DumpArgs = dump.into(); + if let Ok(from_env) = std::env::var("DFPP_DUMP") { + let from_env = DumpArgs::from_str(&from_env, false)?; + dump.0 |= from_env.0; + } + Ok(Args(GArgs { + verbose, + debug, + debug_target, + result_path, + relaxed, + target, + abort_after_analysis, + anactrl, + modelctrl, + dump, + })) + } +} + /// Top level command line arguments +/// +/// There are some shenanigans going on here wrt the `DA` type variable. This is +/// because as of writing these docs Justus can't figure out how to directly +/// collect the dump options into a set, so I first collect them into a vector +/// and then compress it into a set. +/// +/// This is what the `Parseable*` structs are trying to hide from the user. #[derive(serde::Serialize, serde::Deserialize, clap::Args)] -pub struct Args { +struct GArgs { /// Print additional logging output (up to the "info" level) #[clap(short, long, env = "DFPP_VERBOSE")] verbose: bool, @@ -46,8 +105,158 @@ pub struct Args { #[clap(flatten, next_help_heading = "Model Generation")] modelctrl: ModelCtrl, /// Additional arguments that control debug args specifically - #[clap(flatten, next_help_heading = "Debugging and Testing")] - dbg: DbgArgs, + #[clap(flatten)] + dump: DA, +} + +#[derive(serde::Serialize, serde::Deserialize, Clone, clap::Args)] +pub struct ParseableDumpArgs { + /// Generate intermediate of various formats and at various stages of + /// compilation. A short description of each value is provided here, for a + /// more comprehensive explanation refer to the [notion page on + /// dumping](https://www.notion.so/justus-adam/Dumping-Intermediate-Representations-4bd66ec11f8f4c459888a8d8cfb10e93). + /// + /// Can also be supplied as a comma-separated list (no spaces) and be set with the `DFPP_DUMP` variable. + #[clap(long, value_enum)] + dump: Vec, +} + +lazy_static! { + static ref DUMP_ARGS_OPTIONS: Vec = DumpOption::value_variants() + .iter() + .map(|&v| v.into()) + .collect(); +} + +impl clap::ValueEnum for DumpArgs { + fn value_variants<'a>() -> &'a [Self] { + &DUMP_ARGS_OPTIONS + } + + fn to_possible_value(&self) -> Option { + let mut it = self.0.into_iter_set_in_domain(); + let v = it.next().unwrap(); + assert!(it.next().is_none()); + DumpOption::from_u32(v).unwrap().to_possible_value() + } + + fn from_str(input: &str, ignore_case: bool) -> Result { + input + .split(',') + .map(|segment| DumpOption::from_str(segment, ignore_case)) + .collect() + } +} + +impl From for DumpArgs { + fn from(value: DumpOption) -> Self { + [value].into_iter().collect() + } +} + +impl From for DumpArgs { + fn from(value: ParseableDumpArgs) -> Self { + value.dump.into_iter().flat_map(|opt| opt.iter()).collect() + } +} + +/// See [`DumpArgs`] +impl clap::FromArgMatches for DumpArgs { + fn from_arg_matches(_: &clap::ArgMatches) -> Result { + unimplemented!() + } + fn update_from_arg_matches(&mut self, _: &clap::ArgMatches) -> Result<(), clap::Error> { + unimplemented!() + } +} + +/// See [`DumpArgs`] +impl clap::Args for DumpArgs { + fn augment_args(_: clap::Command) -> clap::Command { + unimplemented!() + } + fn augment_args_for_update(_: clap::Command) -> clap::Command { + unimplemented!() + } +} + +/// Collection of the [`DumpOption`]s a user has set. +/// +/// Separates the cli and the internal api. Users set [`DumpOption`]s in the +/// cli, internally we use the snake-case version of the option as a method on +/// this type. This is so we can rename the outer UI without breaking code or +/// even combine options together. +/// +/// As of writing these docs clap doesn't have a way to attach extra constraints +/// to a derived impl (e.g. `Args` of `GArgs`). And so it has to be added to the +/// type variable at the struct definition itself. That means this compressed +/// type, that is only meant to be queried but not parsed needs an impl for +/// these contraints, hence the `undefined!()`. +#[derive(serde::Serialize, serde::Deserialize, Clone)] +pub struct DumpArgs(TinyBitSet); + +impl DumpArgs { + fn iter(self) -> impl Iterator { + self.0 + .into_iter_set_in_domain() + .filter_map(DumpOption::from_u32) + } +} + +impl FromIterator for DumpArgs { + fn from_iter>(iter: T) -> Self { + Self(iter.into_iter().map(|v| v as u32).collect()) + } +} + +#[derive( + Copy, + Clone, + Eq, + PartialEq, + serde::Serialize, + serde::Deserialize, + clap::ValueEnum, + num_derive::FromPrimitive, +)] +enum DumpOption { + /// For each controller dump a dot representation for each [`mir::Body`] as + /// provided by rustc + CtrlMir, + /// For each controller dumps the calculated dataflow graphs as well as + /// information about the MIR to .ntgb.json. Can be + /// deserialized with `crate::dbg::read_non_transitive_graph_and_body`. + SerializedNonTransitiveGraph, + /// Dumps a dot graph representation of the dataflow between function calls + /// calculated for each controller to .call-only-flow.gv + CallOnlyFlow, + /// Dump a complete `crate::desc::ProgramDescription` in serialized (json) + /// format to "flow-graph.json". Used for testing. + SerializedFlowGraph, + /// Dump a `.df` file for each called function describing the dataflow + /// matrices calculated by the flowistry-style dataflow analysis + DataflowAnalysisResult, + /// Dump a `.inlined-pruned.gv` PDG for each called function describing the flow graph + /// after pruning with the place algebra (only useful without `--no-pruning`) + InlinedPrunedGraph, + /// Dump a `.inlined.gv` PDG after inlining called functions, but before pruning + InlinedGraph, + /// Dump the MIR (`.mir`) of each called function (irrespective of whether they are a + /// controller) + CalleeMir, + /// Dump the flow PDG before inlining the called functions + PreInlineGraph, + /// Dump a representation of the "regal" IR for each function (`.regal`) + RegalIr, + /// Dump the equations before inlining (`.local.eqs`) + LocalEquations, + /// Dump the equations after inlining (`.global.eqs`) + GlobalEquations, + LocalsGraph, + /// Deprecated alias for `dump_call_only_flow` + NonTransitiveGraph, + /// Dump everything we know of + All, } /// How a specific logging level was configured. (currently only used for the @@ -76,43 +285,43 @@ impl<'a> LogLevelConfig<'a> { impl Args { pub fn target(&self) -> Option<&str> { - self.target.as_deref() + self.0.target.as_deref() } /// Returns the configuration specified for the `--debug` option pub fn debug(&self) -> Cow<'_, LogLevelConfig<'_>> { - Cow::Owned(match &self.debug_target { + Cow::Owned(match &self.0.debug_target { Some(target) if !target.is_empty() => { LogLevelConfig::Targeted(Cow::Borrowed(target.as_str())) } - _ if self.debug => LogLevelConfig::Enabled, + _ if self.0.debug => LogLevelConfig::Enabled, _ => LogLevelConfig::Disabled, }) } /// Access the debug arguments - pub fn dbg(&self) -> &DbgArgs { - &self.dbg + pub fn dbg(&self) -> &DumpArgs { + &self.0.dump } /// Access the argument controlling the analysis pub fn anactrl(&self) -> &AnalysisCtrl { - &self.anactrl + &self.0.anactrl } pub fn modelctrl(&self) -> &ModelCtrl { - &self.modelctrl + &self.0.modelctrl } /// the file to write results to pub fn result_path(&self) -> &std::path::Path { - self.result_path.as_path() + self.0.result_path.as_path() } /// Should we output additional log messages (level `info`) pub fn verbose(&self) -> bool { - self.verbose + self.0.verbose } /// Warn instead of crashing the program in case of non-fatal errors pub fn relaxed(&self) -> bool { - self.relaxed + self.0.relaxed } pub fn abort_after_analysis(&self) -> bool { - self.abort_after_analysis + self.0.abort_after_analysis } } @@ -299,108 +508,48 @@ impl AnalysisCtrl { } } -/// Arguments that control the output of debug information or output to be -/// consumed for testing. -#[derive(serde::Serialize, serde::Deserialize, clap::Args)] -pub struct DbgArgs { - /// Dumps a table representing retrieved Flowistry matrices to stdout. - #[clap(long, env)] - dump_flowistry_matrix: bool, - /// Dumps a dot graph representation of the finely granular, inlined flow of each controller. - /// Unlike `dump_call_only_flow` this contains also statements and non-call - /// terminators. It is also created differently (using dependency - /// resolution) and has not been tested in a while and shouldn't be relied upon. - #[clap(long, env)] - dump_inlined_function_flow: bool, - /// Dumps a dot graph representation of the dataflow between function calls - /// calculated for each controller to .call-only-flow.gv - #[clap(long, env)] - dump_call_only_flow: bool, - /// Deprecated alias for `dump_call_only_flow` - #[clap(long, env)] - dump_non_transitive_graph: bool, - /// For each controller dumps the calculated dataflow graphs as well as - /// information about the MIR to .ntgb.json. Can be - /// deserialized with `crate::dbg::read_non_transitive_graph_and_body`. - #[clap(long, env)] - dump_serialized_non_transitive_graph: bool, - /// Dump a complete `crate::desc::ProgramDescription` in serialized (json) - /// format to "flow-graph.json". Used for testing. - #[clap(long, env)] - dump_serialized_flow_graph: bool, - /// For each controller dump a dot representation for each [`mir::Body`] as - /// provided by rustc - #[clap(long, env)] - dump_ctrl_mir: bool, - /// Dump a `.df` file for each called function describing the dataflow - /// matrices calculated by the flowistry-style dataflow analysis - #[clap(long, env)] - dump_dataflow_analysis_result: bool, - /// Dump a `.inlined-pruned.gv` PDG for each called function describing the flow graph - /// after pruning with the place algebra (only useful without `--no-pruning`) - #[clap(long, env)] - dump_inlined_pruned_graph: bool, - /// Dump a `.inlined.gv` PDG after inlining called functions, but before pruning - #[clap(long, env)] - dump_inlined_graph: bool, - /// Dump the MIR (`.mir`) of each called function (irrespective of whether they are a - /// controller) - #[clap(long, env)] - dump_callee_mir: bool, - /// Dump the flow PDG before inlining the called functions - #[clap(long, env)] - dump_pre_inline_graph: bool, - /// Dump a representation of the "regal" IR for each function (`.regal`) - #[clap(long, env)] - dump_regal_ir: bool, - /// Dump the equations before inlining (`.local.eqs`) - #[clap(long, env)] - dump_local_equations: bool, - /// Dump the equations after inlining (`.global.eqs`) - #[clap(long, env)] - dump_global_equations: bool, - #[clap(long, env)] - dump_locals_graph: bool, -} - -impl DbgArgs { +impl DumpArgs { + #[inline] + fn has(&self, opt: DumpOption) -> bool { + self.0.contains(DumpOption::All as u32).unwrap() || self.0.contains(opt as u32).unwrap() + } pub fn dump_ctrl_mir(&self) -> bool { - self.dump_ctrl_mir + self.has(DumpOption::CtrlMir) } pub fn dump_serialized_non_transitive_graph(&self) -> bool { - self.dump_serialized_non_transitive_graph + self.has(DumpOption::SerializedNonTransitiveGraph) } pub fn dump_call_only_flow(&self) -> bool { - self.dump_call_only_flow || self.dump_non_transitive_graph + self.has(DumpOption::NonTransitiveGraph) || self.has(DumpOption::CallOnlyFlow) } pub fn dump_serialized_flow_graph(&self) -> bool { - self.dump_serialized_flow_graph + self.has(DumpOption::SerializedFlowGraph) } pub fn dump_dataflow_analysis_result(&self) -> bool { - self.dump_dataflow_analysis_result + self.has(DumpOption::DataflowAnalysisResult) } pub fn dump_inlined_pruned_graph(&self) -> bool { - self.dump_inlined_pruned_graph + self.has(DumpOption::InlinedPrunedGraph) } pub fn dump_inlined_graph(&self) -> bool { - self.dump_inlined_graph + self.has(DumpOption::InlinedGraph) } pub fn dump_callee_mir(&self) -> bool { - self.dump_callee_mir + self.has(DumpOption::CalleeMir) } pub fn dump_pre_inline_graph(&self) -> bool { - self.dump_pre_inline_graph + self.has(DumpOption::PreInlineGraph) } pub fn dump_regal_ir(&self) -> bool { - self.dump_regal_ir + self.has(DumpOption::RegalIr) } pub fn dump_local_equations(&self) -> bool { - self.dump_local_equations + self.has(DumpOption::LocalEquations) } pub fn dump_global_equations(&self) -> bool { - self.dump_global_equations + self.has(DumpOption::GlobalEquations) } pub fn dump_locals_graph(&self) -> bool { - self.dump_locals_graph + self.has(DumpOption::LocalsGraph) } } diff --git a/src/ir/regal.rs b/src/ir/regal.rs index 2a051a3f5e..3e74e8923f 100644 --- a/src/ir/regal.rs +++ b/src/ir/regal.rs @@ -25,7 +25,7 @@ use crate::{ body_name_pls, dump_file_pls, time, write_sep, AsFnAndArgs, AsFnAndArgsErr, DisplayViaDebug, IntoLocalDefId, }, - AnalysisCtrl, DbgArgs, Either, HashMap, HashSet, TyCtxt, + AnalysisCtrl, DumpArgs, Either, HashMap, HashSet, TyCtxt, }; use std::fmt::{Display, Write}; @@ -558,7 +558,7 @@ fn recursive_ctrl_deps< } pub fn compute_from_body_id<'tcx>( - dbg_opts: &DbgArgs, + dbg_opts: &DumpArgs, body_id: BodyId, tcx: TyCtxt<'tcx>, gli: GLI, diff --git a/src/lib.rs b/src/lib.rs index bee76f81b8..62780a9ee5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,6 +26,9 @@ extern crate humantime; extern crate petgraph; +extern crate num_derive; +extern crate num_traits; + #[macro_use] pub extern crate rustc_index; extern crate rustc_serialize; @@ -64,7 +67,7 @@ pub mod rust { pub use mir::Location; } -use args::LogLevelConfig; +use args::{LogLevelConfig, ParseableArgs}; use pretty::DocBuilder; use rust::*; @@ -93,7 +96,7 @@ pub mod serializers; pub mod utils; pub mod consts; -pub use args::{AnalysisCtrl, Args, DbgArgs, ModelCtrl}; +pub use args::{AnalysisCtrl, Args, DumpArgs, ModelCtrl}; use crate::utils::outfile_pls; @@ -114,7 +117,7 @@ struct ArgWrapper { /// The actual arguments #[clap(flatten)] - args: Args, + args: ParseableArgs, /// Pass through for additional cargo arguments (like --features) #[clap(last = true)] @@ -236,7 +239,7 @@ impl rustc_plugin::RustcPlugin for DfppPlugin { use clap::Parser; let args = ArgWrapper::parse(); rustc_plugin::RustcPluginArgs { - args: args.args, + args: Args::from_parseable(args.args).unwrap(), filter: CrateFilter::OnlyWorkspace, } } diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 41b1537b30..d924697f44 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -96,8 +96,11 @@ where S: AsRef, { dfpp_command(dir) - .arg("--abort-after-analysis") - .arg("--dump-serialized-non-transitive-graph") + .args([ + "--abort-after-analysis", + "--dump", + "serialized-non-transitive-graph", + ]) .args(extra) .status() .unwrap() @@ -123,8 +126,7 @@ where S: AsRef, { dfpp_command(dir) - .arg("--abort-after-analysis") - .arg("--dump-serialized-flow-graph") + .args(["--abort-after-analysis", "--dump", "serialized-flow-graph"]) .args(extra) .status() .unwrap()