MIR: hide .rodata constants vs by-ref ABI clash in trans.
This commit is contained in:
parent
d0f8e2913a
commit
6db68938ac
7 changed files with 36 additions and 23 deletions
|
|
@ -31,21 +31,15 @@ fn main() {
|
|||
// | Live variables at bb0[0]: []
|
||||
// StorageLive(_1);
|
||||
// | Live variables at bb0[1]: []
|
||||
// StorageLive(_2);
|
||||
// | Live variables at bb0[2]: []
|
||||
// _2 = const 22usize;
|
||||
// | Live variables at bb0[3]: [_2]
|
||||
// _1 = const <std::boxed::Box<T>>::new(_2) -> bb1;
|
||||
// _1 = const <std::boxed::Box<T>>::new(const 22usize) -> bb1;
|
||||
// }
|
||||
// END rustc.main.nll.0.mir
|
||||
// START rustc.main.nll.0.mir
|
||||
// | Live variables on entry to bb1: [_1 (drop)]
|
||||
// bb1: {
|
||||
// | Live variables at bb1[0]: [_1 (drop)]
|
||||
// StorageDead(_2);
|
||||
// StorageLive(_2);
|
||||
// | Live variables at bb1[1]: [_1 (drop)]
|
||||
// StorageLive(_3);
|
||||
// | Live variables at bb1[2]: [_1 (drop)]
|
||||
// _3 = const can_panic() -> [return: bb2, unwind: bb4];
|
||||
// _2 = const can_panic() -> [return: bb2, unwind: bb4];
|
||||
// }
|
||||
// END rustc.main.nll.0.mir
|
||||
|
|
|
|||
|
|
@ -46,5 +46,5 @@ impl<T> Drop for Wrap<T> {
|
|||
|
||||
// END RUST SOURCE
|
||||
// START rustc.main.nll.0.mir
|
||||
// | '_#5r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb3[1], bb3[2], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb7[2], bb8[0]}
|
||||
// | '_#5r: {bb1[3], bb1[4], bb1[5], bb2[0], bb2[1], bb2[2], bb3[0], bb4[0], bb4[1], bb4[2], bb6[0], bb7[0], bb7[1], bb8[0]}
|
||||
// END rustc.main.nll.0.mir
|
||||
|
|
|
|||
|
|
@ -45,5 +45,5 @@ fn main() {
|
|||
// ...
|
||||
// _2 = &'_#1r _1[_3];
|
||||
// ...
|
||||
// _2 = &'_#3r (*_11);
|
||||
// _2 = &'_#3r (*_10);
|
||||
// END rustc.main.nll.0.mir
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(fn_traits)]
|
||||
#![feature(fn_traits, test)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
fn test1(a: isize, b: (i32, i32), c: &[i32]) -> (isize, (i32, i32), &[i32]) {
|
||||
// Test passing a number of arguments including a fat pointer.
|
||||
|
|
@ -156,6 +158,16 @@ fn test_fn_nested_pair(x: &((f32, f32), u32)) -> (f32, f32) {
|
|||
(z.0, z.1)
|
||||
}
|
||||
|
||||
fn test_fn_const_arg_by_ref(mut a: [u64; 4]) -> u64 {
|
||||
// Mutate the by-reference argument, which won't work with
|
||||
// a non-immediate constant unless it's copied to the stack.
|
||||
let a = test::black_box(&mut a);
|
||||
a[0] += a[1];
|
||||
a[0] += a[2];
|
||||
a[0] += a[3];
|
||||
a[0]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(test1(1, (2, 3), &[4, 5, 6]), (1, (2, 3), &[4, 5, 6][..]));
|
||||
assert_eq!(test2(98), 98);
|
||||
|
|
@ -182,4 +194,7 @@ fn main() {
|
|||
assert_eq!(test_fn_ignored_pair_0(), ());
|
||||
assert_eq!(test_fn_ignored_pair_named(), (Foo, Foo));
|
||||
assert_eq!(test_fn_nested_pair(&((1.0, 2.0), 0)), (1.0, 2.0));
|
||||
|
||||
const ARRAY: [u64; 4] = [1, 2, 3, 4];
|
||||
assert_eq!(test_fn_const_arg_by_ref(ARRAY), 1 + 2 + 3 + 4);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue