about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2018-11-11 00:21:19 +0100
committerGitHub <noreply@github.com>2018-11-11 00:21:19 +0100
commit5b0b0ce61ebf0da19d89f1be7ccea67f6cd128a7 (patch)
tree3f040a23fb74bb89768b399b888e0d49749b84ab /src/test
parent18195d413333d8d9ab5d1ed6a5af2993c0c8e5d8 (diff)
parent3cce5c79778088a26f6099f293256d5d7834fdb3 (diff)
downloadrust-5b0b0ce61ebf0da19d89f1be7ccea67f6cd128a7.tar.gz
rust-5b0b0ce61ebf0da19d89f1be7ccea67f6cd128a7.zip
Rollup merge of #55802 - wesleywiser:inlined_calls_2_electric_boogaloo, r=nagisa
Don't inline virtual calls (take 2)

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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/mir-opt/inline-trait-method_2.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/mir-opt/inline-trait-method_2.rs b/src/test/mir-opt/inline-trait-method_2.rs
new file mode 100644
index 00000000000..aa756f4a233
--- /dev/null
+++ b/src/test/mir-opt/inline-trait-method_2.rs
@@ -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