Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
nightly-2023-07-28
Browse files Browse the repository at this point in the history
  • Loading branch information
hermanventer committed Jul 29, 2023
1 parent 3787414 commit 99e9fc5
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 56 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

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

Binary file modified binaries/summary_store.tar
Binary file not shown.
2 changes: 1 addition & 1 deletion checker/src/block_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3317,7 +3317,7 @@ impl<'block, 'analysis, 'compilation, 'tcx> BlockVisitor<'block, 'analysis, 'com
&bytes[size..]
},
TyKind::Uint(UintTy::U8) => unsafe {
let uint_ptr = bytes.as_ptr() as *const u8;
let uint_ptr = bytes.as_ptr();
let u = self.bv.get_u128_const_val((*uint_ptr) as u128);
self.bv.update_value_at(target_path, u);
&bytes[1..]
Expand Down
2 changes: 1 addition & 1 deletion checker/src/body_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl<'analysis, 'compilation, 'tcx> BodyVisitor<'analysis, 'compilation, 'tcx> {
let dominators = self.mir.basic_blocks.dominators();
for (location1, callee_defid1) in self.block_to_call.iter() {
for (location2, callee_defid2) in self.block_to_call.iter() {
if location1 != location2 && location1.dominates(*location2, &dominators) {
if location1 != location2 && location1.dominates(*location2, dominators) {
self.cv.call_graph.add_dom(*callee_defid1, *callee_defid2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion checker/src/fixed_point_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'fixed, 'analysis, 'compilation, 'tcx>
body_visitor: &'fixed mut BodyVisitor<'analysis, 'compilation, 'tcx>,
) -> FixedPointVisitor<'fixed, 'analysis, 'compilation, 'tcx> {
let dominators = body_visitor.mir.basic_blocks.dominators();
let (block_indices, loop_anchors) = get_sorted_block_indices(body_visitor.mir, &dominators);
let (block_indices, loop_anchors) = get_sorted_block_indices(body_visitor.mir, dominators);
// in_state[bb] is the join (or widening) of the out_state values of each predecessor of bb
let mut in_state: HashMap<mir::BasicBlock, Environment> = HashMap::new();
// out_state[bb] is the environment that results from analyzing block bb, given in_state[bb]
Expand Down
4 changes: 3 additions & 1 deletion checker/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,9 @@ impl PathRefinement for Rc<Path> {
}

if let PathEnum::Offset { value } = &self.value {
let Expression::Offset { left, right } = &value.expression else {unreachable!()};
let Expression::Offset { left, right } = &value.expression else {
unreachable!()

Check warning on line 897 in checker/src/path.rs

View check run for this annotation

Codecov / codecov/patch

checker/src/path.rs#L897

Added line #L897 was not covered by tests
};
if let Expression::Variable { path, var_type } = &left.expression {
let canonical_left_path = path.canonicalize(environment);
let canonical_lef_var =
Expand Down
2 changes: 1 addition & 1 deletion checker/src/summaries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn extract_reachable_heap_allocations(
}
}
}
heap_roots.extend(new_roots.into_iter());
heap_roots.extend(new_roots);
}
}

Expand Down
12 changes: 6 additions & 6 deletions checker/tests/call_graph/fnptr_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ commit;
/* EXPECTED:CALL_SITES{
"files": [
"tests/call_graph/fnptr_fold.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/std/src/io/stdio.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/fmt/mod.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/slice/mod.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/ptr/metadata.rs"
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/std/src/io/stdio.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/fmt/mod.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/slice/mod.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/ptr/metadata.rs"
],
"callables": [
{
Expand Down Expand Up @@ -113,7 +113,7 @@ commit;
{
"name": "/core/core::slice::<impl [T]>::len(&[T])->usize",
"file_index": 3,
"first_line": 140,
"first_line": 141,
"local": true
},
{
Expand Down Expand Up @@ -175,7 +175,7 @@ commit;
],
[
3,
141,
142,
9,
6,
7
Expand Down
12 changes: 6 additions & 6 deletions checker/tests/call_graph/static_fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ commit;
/* EXPECTED:CALL_SITES{
"files": [
"tests/call_graph/static_fold.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/std/src/io/stdio.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/fmt/mod.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/slice/mod.rs",
"/rustc/8b4b20836b832e91aa605a2faf5e2a55190202c8/library/core/src/ptr/metadata.rs"
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/std/src/io/stdio.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/fmt/mod.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/slice/mod.rs",
"/rustc/500647fd8138cc09e87edb08d62f81654fbf6ef8/library/core/src/ptr/metadata.rs"
],
"callables": [
{
Expand Down Expand Up @@ -109,7 +109,7 @@ commit;
{
"name": "/core/core::slice::<impl [T]>::len(&[T])->usize",
"file_index": 3,
"first_line": 140,
"first_line": 141,
"local": true
},
{
Expand Down Expand Up @@ -157,7 +157,7 @@ commit;
],
[
3,
141,
142,
9,
6,
7
Expand Down
36 changes: 22 additions & 14 deletions checker/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extern crate rayon;
extern crate rustc_ast;
extern crate rustc_data_structures;
extern crate rustc_driver;
extern crate rustc_session;
extern crate tempfile;

use std::collections::HashMap;
Expand All @@ -31,6 +32,7 @@ use std::str::FromStr;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use regex::Regex;
use rustc_session::*;
use serde::Deserialize;
use tempfile::TempDir;
use walkdir::WalkDir;
Expand Down Expand Up @@ -148,9 +150,9 @@ fn run_directory(directory_path: PathBuf) -> Vec<(String, String)> {
files_and_temp_dirs
}

fn build_options() -> Options {
fn build_options(early_error_handler: &EarlyErrorHandler) -> Options {
let mut options = Options::default();
options.parse_from_str("", true); // get defaults
options.parse_from_str("", early_error_handler, true); // get defaults
options.diag_level = DiagLevel::Paranoid; // override default
options.max_analysis_time_for_body = 20;
options.max_analysis_time_for_crate = 60;
Expand Down Expand Up @@ -254,6 +256,7 @@ fn invoke_driver_on_files(
// Runs the single test case found in file_name, using temp_dir_path as the place
// to put compiler output, which for Mirai includes the persistent summary store.
fn invoke_driver(
early_error_handler: &EarlyErrorHandler,
file_name: String,
temp_dir_path: String,
sys_root: String,
Expand All @@ -265,7 +268,8 @@ fn invoke_driver(
let file_content = read_to_string(Path::new(&file_name)).unwrap();
let options_re = Regex::new(r"(?m)^\s*//\s*MIRAI_FLAGS\s(?P<flags>.*)$").unwrap();
if let Some(captures) = options_re.captures(&file_content) {
rustc_args = options.parse_from_str(&captures["flags"], true); // override based on test source
rustc_args = options.parse_from_str(&captures["flags"], early_error_handler, true);
// override based on test source
}
}

Expand Down Expand Up @@ -406,15 +410,15 @@ fn check_call_graph_output(
if compare_lines(&expected, &actual) {
0
} else {
// println!("{file_name} failed to match {output_type:?} output");
// println!("Expected:\n{expected}");
// println!("Actual:\n{actual}");
// 1
let c = expected_regex.captures(&test_case_data).unwrap();
let updated =
expected_regex.replace(&test_case_data, format!("{}{actual}{}", &c[1], &c[3]));
fs::write(Path::new(&file_name), updated.to_string()).unwrap();
0
println!("{file_name} failed to match {output_type:?} output");
println!("Expected:\n{expected}");
println!("Actual:\n{actual}");
1
// let c = expected_regex.captures(&test_case_data).unwrap();
// let updated =
// expected_regex.replace(&test_case_data, format!("{}{actual}{}", &c[1], &c[3]));
// fs::write(Path::new(&file_name), updated.to_string()).unwrap();
// 0
}
} else {
println!("{file_name} failed to read {output_type:?} output");
Expand All @@ -424,9 +428,11 @@ fn check_call_graph_output(

// Default test driver
fn start_driver(config: DriverConfig) -> usize {
let early_error_handler = EarlyErrorHandler::new(config::ErrorOutputType::default());
let sys_root = utils::find_sysroot();
let options = build_options();
let options = build_options(&early_error_handler);
self::invoke_driver(
&early_error_handler,
config.file_name,
config.temp_dir_path,
sys_root,
Expand All @@ -438,12 +444,14 @@ fn start_driver(config: DriverConfig) -> usize {
// Test driver for call graph generation;
// sets up call graph configuration.
fn start_driver_call_graph(config: DriverConfig) -> usize {
let early_error_handler = EarlyErrorHandler::new(config::ErrorOutputType::default());
let sys_root = utils::find_sysroot();
let mut options = build_options();
let mut options = build_options(&early_error_handler);
let (call_graph_config, call_graph_config_path) =
generate_call_graph_config(&config.file_name, &config.temp_dir_path);
options.call_graph_config = Some(call_graph_config_path);
let result = self::invoke_driver(
&early_error_handler,
config.file_name.clone(),
config.temp_dir_path.clone(),
sys_root,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-07-18"
channel = "nightly-2023-07-28"
components = [ "clippy", "rustfmt", "rustc-dev", "rust-src", "rust-std", "llvm-tools-preview" ]
47 changes: 31 additions & 16 deletions standard_contracts/src/foreign_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2867,22 +2867,37 @@ pub mod core {
) {
std::intrinsics::copy_nonoverlapping(src, dst, count);
}
// pub fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: usize) {}
// pub fn volatile_set_memory<T>(dst: *mut T, val: T, count: usize) {
// *dst = val;
// }
// pub fn volatile_load<T>(src: *const T) -> T {
// *src
// }
// pub fn volatile_store<T>(dst: *mut T, val: T) {
// *dst = val;
// }
// pub fn unaligned_volatile_load<T>(src: *const T) -> T {
// *src
// }
// pub fn unaligned_volatile_store<T>(dst: *mut T, val: T) {
// *dst = val
// }
pub unsafe fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: usize) {
std::intrinsics::copy_nonoverlapping(src, dst, count);
}
pub unsafe fn volatile_set_memory<T>(dst: *mut T, val: T, count: usize) {
// todo: add a intrinsic function for this to MIRAI
*dst = val;
}
pub unsafe fn volatile_load<T>(src: *const T) -> T
where
T: Copy,
{
*src
}
pub unsafe fn volatile_store<T>(dst: *mut T, val: T)
where
T: Copy,
{
*dst = val;
}
pub unsafe fn unaligned_volatile_load<T>(src: *const T) -> T
where
T: Copy,
{
*src
}
pub unsafe fn unaligned_volatile_store<T>(dst: *mut T, val: T)
where
T: Copy,
{
*dst = val
}

default_contract!(float_to_int_unchecked);
pub fn fmaf32(a: f32, b: f32, c: f32) -> f32 {
Expand Down

0 comments on commit 99e9fc5

Please sign in to comment.