-
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.
When I fixed the previous mis-optimizations, I didn't realize there were actually two different places where we mutate `callsites` and both of them should have the same behavior. As a result, if a function was inlined and that function contained virtual function calls, they were incorrectly being inlined. I also added a test case which covers this.
- Loading branch information
1 parent
36a50c2
commit 3cce5c7
Showing
2 changed files
with
85 additions
and
45 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
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,36 @@ | ||
// compile-flags: -Z span_free_formats -Z mir-opt-level=3 | ||
|
||
#[inline] | ||
fn test(x: &dyn X) -> bool { | ||
x.y() | ||
} | ||
|
||
fn test2(x: &dyn X) -> bool { | ||
test(x) | ||
} | ||
|
||
trait X { | ||
fn y(&self) -> bool { | ||
false | ||
} | ||
} | ||
|
||
impl X for () { | ||
fn y(&self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
fn main() { | ||
println!("Should be true: {}", test2(&())); | ||
} | ||
|
||
// END RUST SOURCE | ||
// START rustc.test2.Inline.after.mir | ||
// ... | ||
// bb0: { | ||
// ... | ||
// _0 = const X::y(move _2) -> bb1; | ||
// } | ||
// ... | ||
// END rustc.test2.Inline.after.mir |