-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite sepcomp-inlining and -separate to rmake.rs
- Loading branch information
Showing
10 changed files
with
75 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3421,7 +3421,6 @@ dependencies = [ | |
"ar", | ||
"bstr", | ||
"gimli 0.28.1", | ||
"glob", | ||
"object 0.34.0", | ||
"regex", | ||
"similar", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Check that cross-crate inlined items are inlined in all compilation units | ||
// that refer to them, and not in any other compilation units. | ||
// Note that we have to pass `-C codegen-units=6` because up to two CGUs may be | ||
// created for each source module (see `rustc_const_eval::monomorphize::partitioning`). | ||
// See https://github.com/rust-lang/rust/pull/16367 | ||
|
||
use run_make_support::{cwd, fs_wrapper, has_extension, regex, rustc, shallow_find_files}; | ||
|
||
fn main() { | ||
rustc().input("cci_lib.rs").run(); | ||
rustc().input("foo.rs").emit("llvm-ir").codegen_units(6).arg("-Zinline-in-all-cgus").run(); | ||
let re = regex::Regex::new(r#"define\ .*cci_fn"#).unwrap(); | ||
assert_eq!(count_regex_matches_in_files_with_extension(&re, "ll"), 2); | ||
} | ||
|
||
fn count_regex_matches_in_files_with_extension(re: ®ex::Regex, ext: &str) -> usize { | ||
let fetched_files = shallow_find_files(cwd(), |path| has_extension(path, ext)); | ||
|
||
let mut count = 0; | ||
for file in fetched_files { | ||
let content = fs_wrapper::read_to_string(file); | ||
count += content.lines().filter(|line| re.is_match(&line)).count(); | ||
} | ||
|
||
count | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Test that #[inline] functions still get inlined across compilation unit | ||
// boundaries. Compilation should produce three IR files, but only the two | ||
// compilation units that have a usage of the #[inline] function should | ||
// contain a definition. Also, the non-#[inline] function should be defined | ||
// in only one compilation unit. | ||
// See https://github.com/rust-lang/rust/pull/16367 | ||
|
||
use run_make_support::{cwd, fs_wrapper, has_extension, regex, rustc, shallow_find_files}; | ||
|
||
fn main() { | ||
rustc().input("foo.rs").emit("llvm-ir").codegen_units(3).arg("-Zinline-in-all-cgus").run(); | ||
let re = regex::Regex::new(r#"define\ i32\ .*inlined"#).unwrap(); | ||
assert_eq!(count_regex_matches_in_files_with_extension(&re, "ll"), 0); | ||
let re = regex::Regex::new(r#"define\ internal\ .*inlined"#).unwrap(); | ||
assert_eq!(count_regex_matches_in_files_with_extension(&re, "ll"), 2); | ||
let re = regex::Regex::new(r#"define\ hidden\ i32\ .*normal"#).unwrap(); | ||
assert_eq!(count_regex_matches_in_files_with_extension(&re, "ll"), 1); | ||
let re = regex::Regex::new(r#"declare\ hidden\ i32\ .*normal"#).unwrap(); | ||
assert_eq!(count_regex_matches_in_files_with_extension(&re, "ll"), 2); | ||
} | ||
|
||
fn count_regex_matches_in_files_with_extension(re: ®ex::Regex, ext: &str) -> usize { | ||
let fetched_files = shallow_find_files(cwd(), |path| has_extension(path, ext)); | ||
|
||
let mut count = 0; | ||
for file in fetched_files { | ||
let content = fs_wrapper::read_to_string(file); | ||
count += content.lines().filter(|line| re.is_match(&line)).count(); | ||
} | ||
|
||
count | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters