Skip to content

Commit

Permalink
Auto merge of #53356 - michaelwoerister:itlto, r=alexcrichton
Browse files Browse the repository at this point in the history
Preliminary work for incremental ThinLTO (CGU name edition)

Bring back the first half of #52266 but hopefully without the performance regression.
  • Loading branch information
bors committed Aug 17, 2018
2 parents 73d6a87 + 60b3bea commit a2513fb
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2209,12 +2209,12 @@ impl<'test> TestCx<'test> {
.stdout
.lines()
.filter(|line| line.starts_with(PREFIX))
.map(str_to_mono_item)
.map(|line| str_to_mono_item(line, true))
.collect();

let expected: Vec<MonoItem> = errors::load_errors(&self.testpaths.file, None)
.iter()
.map(|e| str_to_mono_item(&e.msg[..]))
.map(|e| str_to_mono_item(&e.msg[..], false))
.collect();

let mut missing = Vec::new();
Expand Down Expand Up @@ -2299,14 +2299,14 @@ impl<'test> TestCx<'test> {
}

// [MONO_ITEM] name [@@ (cgu)+]
fn str_to_mono_item(s: &str) -> MonoItem {
fn str_to_mono_item(s: &str, cgu_has_crate_disambiguator: bool) -> MonoItem {
let s = if s.starts_with(PREFIX) {
(&s[PREFIX.len()..]).trim()
} else {
s.trim()
};

let full_string = format!("{}{}", PREFIX, s.trim().to_owned());
let full_string = format!("{}{}", PREFIX, s);

let parts: Vec<&str> = s
.split(CGU_MARKER)
Expand All @@ -2323,7 +2323,13 @@ impl<'test> TestCx<'test> {
.split(' ')
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_owned)
.map(|s| {
if cgu_has_crate_disambiguator {
remove_crate_disambiguator_from_cgu(s)
} else {
s.to_string()
}
})
.collect()
} else {
HashSet::new()
Expand All @@ -2348,6 +2354,23 @@ impl<'test> TestCx<'test> {

string
}

fn remove_crate_disambiguator_from_cgu(cgu: &str) -> String {
// The first '.' is the start of the crate disambiguator
let disambiguator_start = cgu.find('.')
.expect("Could not find start of crate disambiguator in CGU spec");

// The first non-alphanumeric character is the end of the disambiguator
let disambiguator_end = cgu[disambiguator_start + 1 ..]
.find(|c| !char::is_alphanumeric(c))
.expect("Could not find end of crate disambiguator in CGU spec")
+ disambiguator_start + 1;

let mut result = cgu[0 .. disambiguator_start].to_string();
result.push_str(&cgu[disambiguator_end ..]);

result
}
}

fn init_incremental_test(&self) {
Expand Down

0 comments on commit a2513fb

Please sign in to comment.