Skip to content

Commit

Permalink
SOSP improvements (#149)
Browse files Browse the repository at this point in the history
## What Changed?

- Improves soundness of marker assignment logic.
- Refactors the graph constructor into it's own file
- The Graph query API is now accessible as methods on nodes
- Implements adaptive inlining optimization
- Improves error messages from parse failures for the annotations
- Switches output serialization format to bincode by default
- Adds a new framework and suite of tests based on the policy framework
- Adds tracing to always_happens_before
- Generics on entry points are now handled by providing arguments of
type `dyn <constraints>`
- Adds statistics on runtime to flow analyzer and policies
- Materialized `flows_to` relations are now optional
- Diagnostics are now deduplicated

## Why Does It Need To?

Improves soundness, ergonomics and speed.

Fixes #129 
Fixes #130 

## Checklist

- [x] Above description has been filled out so that upon quash merge we
have a
  good record of what changed.
- [ ] New functions, methods, types are documented. Old documentation is
updated
  if necessary
- [ ] Documentation in Notion has been updated
- [ ] Tests for new behaviors are provided
  - [ ] New test suites (if any) ave been added to the CI tests (in
`.github/workflows/rust.yml`) either as compiler test or integration
test.
*Or* justification for their omission from CI has been provided in this
PR
    description.

---------

Co-authored-by: Carolyn Zech <[email protected]>
Co-authored-by: Will Crichton <[email protected]>
  • Loading branch information
3 people authored May 2, 2024
1 parent 7f7c080 commit 074d847
Show file tree
Hide file tree
Showing 58 changed files with 7,373 additions and 1,804 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ flow-graph.json

.DS_Store
*.flowistry-pdg.pdf

*.mir
*.o
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"unresolved-proc-macro"
],
"rust-analyzer.rustc.source": "discover",
"rust-analyzer.workspace.symbol.search.scope": "workspace_and_dependencies"
"rust-analyzer.workspace.symbol.search.scope": "workspace_and_dependencies",
"rust-analyzer.showUnlinkedFileNotification": false
}
42 changes: 39 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ anyhow = { version = "1.0.72", features = ["backtrace"] }
[profile.release]
debug = true

#[replace]
#"rustc_utils:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "80d92411810c709522119407be24745555adc87a" }
#"rustc_plugin:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "80d92411810c709522119407be24745555adc87a" }
# [replace]
# "rustc_utils:0.7.4-nightly-2023-08-25" = { path = "../rustc_plugin/crates/rustc_utils" }
# "rustc_plugin:0.7.4-nightly-2023-08-25" = { path = "../rustc_plugin/crates/rustc_plugin" }
9 changes: 3 additions & 6 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ args = ["install", "--locked", "--path", "crates/paralegal-flow"]

[tasks.pdg-tests]
description = "The suite of synthetic tests for the PDG and the policy framweork."
dependencies = [
"analyzer-tests",
"policy-framework-tests",
"guide-project",
]
dependencies = ["analyzer-tests", "policy-framework-tests", "guide-project"]

[tasks.check-all]
description = "Perform all formatting-like checks. This is the same set that runs in the CI."
Expand Down Expand Up @@ -68,6 +64,7 @@ args = [
"new_alias_analysis_tests",
"--test",
"async_tests",
"--no-fail-fast",
]

[tasks.policy-framework-tests]
Expand Down Expand Up @@ -221,6 +218,6 @@ dependencies = ["clean-rustc-docs-location"]
[tasks.clean-rustc-docs-location]
command = "rm"
args = [
"-f",
"-rf",
"${RUSTUP_HOME}/toolchains/${RUSTUP_TOOLCHAIN}/share/doc/rust/html/rustc",
]
2 changes: 1 addition & 1 deletion crates/flowistry_pdg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ cfg-if = "1.0.0"
internment = { version = "0.7.4", features = ["serde"] }

strum = { workspace = true }
serde = { workspace = true }
serde = { workspace = true, features = ["derive"] }
2 changes: 1 addition & 1 deletion crates/flowistry_pdg/src/rustc_portable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! The idea is that you can then define your data structure over this
//! (including serialization) like so, using `cfg_attr:
//!
//! ```
//! ```ignore
//! pub struct GlobalLocationS {
//! #[cfg_attr(feature = "rustc", serde(with = "rustc_proxies::BodyId"))]
//! pub function: BodyId,
Expand Down
6 changes: 3 additions & 3 deletions crates/flowistry_pdg_construction/src/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,18 @@ impl<'tcx> PdgParams<'tcx> {
/// ```
/// # #![feature(rustc_private)]
/// # extern crate rustc_middle;
/// # use flowistry_pdg_construction::{PdgParams, SkipCall, CallChanges};
/// # use flowistry_pdg_construction::{PdgParams, SkipCall, CallChanges, CallChangeCallbackFn};
/// # use rustc_middle::ty::TyCtxt;
/// # const THRESHOLD: usize = 5;
/// # fn f<'tcx>(tcx: TyCtxt<'tcx>, params: PdgParams<'tcx>) -> PdgParams<'tcx> {
/// params.with_call_change_callback(|info| {
/// params.with_call_change_callback(CallChangeCallbackFn::new(|info| {
/// let skip = if info.call_string.len() > THRESHOLD {
/// SkipCall::Skip
/// } else {
/// SkipCall::NoSkip
/// };
/// CallChanges::default().with_skip(skip)
/// })
/// }))
/// # }
/// ```
pub fn with_call_change_callback(self, f: impl CallChangeCallback<'tcx> + 'tcx) -> Self {
Expand Down
19 changes: 8 additions & 11 deletions crates/paralegal-flow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,27 @@ ordermap = "0.3"
trait_enum = "0.5"
pretty = "0.11"
nom = "7"
log = "0.4"
log = { version = "0.4", features = ["serde"] }
simple_logger = "2"
num-derive = "0.4"
num-traits = "0.2"
petgraph = { workspace = true }
humantime = "2"
strum = { workspace = true }

enum-map = "2.7"
serial_test = "2.0.0"
itertools = "0.12"
anyhow = "1.0.72"
thiserror = "1"
serde_bare = "0.5.0"
toml = "0.7"

#dot = "0.1"
dot = { git = "https://github.com/JustusAdam/dot-rust", rev = "ff2b42ceda98c639c8ea3cbfc56b83d6e06e8106" }
#dot = {path = "../../clones/dot-rust" }

serde_bare = "0.5.0"
serde_json = "1"
toml = "0.7"


# This is just for pinning this dependency
camino = "= 1.0.9"
serial_test = "2.0.0"
itertools = "0.12"
anyhow = "1.0.72"
thiserror = "1"

[build-dependencies]
chrono = "0.4"
Expand Down
10 changes: 10 additions & 0 deletions crates/paralegal-flow/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,14 @@ fn main() {

let toolchain_path = rustup_toolchain_path();
println!("cargo:rustc-env=SYSROOT_PATH={}", toolchain_path.display());

let rustc_path = std::env::var("RUSTC").unwrap();
let rustc_version = std::process::Command::new(rustc_path)
.arg("--version")
.output()
.unwrap();
println!(
"cargo:rustc-env=RUSTC_VERSION=\"{}\"",
String::from_utf8(rustc_version.stdout).unwrap()
);
}
Loading

0 comments on commit 074d847

Please sign in to comment.