Update mir-opt filechecks

This commit is contained in:
Scott McMurray 2024-08-18 15:51:53 -07:00
parent 32185decd6
commit 249a36ffbd
45 changed files with 356 additions and 356 deletions

View File

@ -15,7 +15,7 @@ fn main() {
// CHECK: debug x => [[x:_.*]];
// CHECK: debug y => [[y:_.*]];
// CHECK: [[y]] = const 1_usize;
// CHECK: [[tmp:_.*]] = [[y]];
// CHECK: [[tmp:_.*]] = copy [[y]];
// CHECK: [[x]][[[tmp]]] =
let mut x = [42, 43, 44];
let mut y = 1;

View File

@ -7,7 +7,7 @@
fn main() {
// CHECK-LABEL: fn main(
// CHECK: [[box:_.*]] = ShallowInitBox(
// CHECK: [[ptr:_.*]] = ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S);
// CHECK: [[ptr:_.*]] = copy ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S);
// CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]];
// CHECK: [[ret]]: {
// CHECK: [[box2:_.*]] = move [[box]];

View File

@ -25,7 +25,7 @@ fn disjoint_ranges(x: i32, b: bool) -> u32 {
// CHECK-LABEL: fn disjoint_ranges(
// CHECK: debug b => _2;
// CHECK: bb0: {
// CHECK: switchInt(_2) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}];
// CHECK: switchInt(copy _2) -> [0: [[jump:bb.*]], otherwise: {{bb.*}}];
// CHECK: [[jump]]: {
// CHECK-NEXT: _0 = const 3_u32;
// CHECK-NEXT: return;

View File

@ -15,7 +15,7 @@ fn while_loop(c: bool) {
// CHECK: bb1: {
// CHECK-NEXT: StorageLive(_3);
// CHECK-NEXT: StorageLive(_2);
// CHECK-NEXT: _2 = _1;
// CHECK-NEXT: _2 = copy _1;
// CHECK-NEXT: _3 = get_bool(move _2) -> [return: bb2, unwind
// CHECK: bb2: {
// CHECK-NEXT: switchInt(move _3) -> [0: bb3, otherwise: bb4];
@ -29,7 +29,7 @@ fn while_loop(c: bool) {
// CHECK-NEXT: StorageDead(_2);
// CHECK-NEXT: StorageLive(_5);
// CHECK-NEXT: StorageLive(_4);
// CHECK-NEXT: _4 = _1;
// CHECK-NEXT: _4 = copy _1;
// CHECK-NEXT: _5 = get_bool(move _4) -> [return: bb5, unwind
// CHECK: bb5: {
// CHECK-NEXT: switchInt(move _5) -> [0: bb6, otherwise: bb7];

View File

@ -10,13 +10,13 @@ pub fn fn0() -> bool {
// CHECK: (*[[ptr]]) = const true;
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
// CHECK: [[tmp:_.*]] = ([[pair]].1: bool);
// CHECK: [[tmp:_.*]] = copy ([[pair]].1: bool);
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
// CHECK: [[ret]] = Not(move [[tmp]]);
// CHECK-NOT: = const false;
// CHECK-NOT: = const true;
// CHECK: _0 = [[ret]];
// CHECK: _0 = copy [[ret]];
let mut pair = (1, false);
let ptr = core::ptr::addr_of_mut!(pair.1);
pair = (1, false);

View File

@ -8,7 +8,7 @@ fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug a => [[a:_.*]];
// CHECK: debug _b => [[b:_.*]];
// CHECK: [[b]] = (*[[a]])[3 of 4];
// CHECK: [[b]] = copy (*[[a]])[3 of 4];
let a: *const [_] = &[1, 2, 3];
unsafe {
let _b = (*a)[3];

View File

@ -11,8 +11,8 @@ fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug x => [[x:_.*]];
// CHECK: (*{{_.*}}) = const 42_i32;
// CHECK: [[tmp:_.*]] = (*{{_.*}});
// CHECK: [[x]] = [[tmp]];
// CHECK: [[tmp:_.*]] = copy (*{{_.*}});
// CHECK: [[x]] = copy [[tmp]];
let x = *(#[rustc_box]
Box::new(42))
+ 0;

View File

@ -10,7 +10,7 @@ fn foo() {
// CHECK: _1 = const (1_i32,);
// CHECK: _2 = &mut (_1.0: i32);
// CHECK: (*_2) = const 5_i32;
// CHECK: _4 = (_1.0: i32);
// CHECK: _4 = copy (_1.0: i32);
// CHECK: _3 = Eq(move _4, const 5_i32);
let mut u = (1,);
@ -25,7 +25,7 @@ fn bar() {
// CHECK: debug y => _4;
// CHECK: _3 = &raw mut (_1.0: i32);
// CHECK: (*_3) = const 5_i32;
// CHECK: _5 = (_1.0: i32);
// CHECK: _5 = copy (_1.0: i32);
// CHECK: _4 = Eq(move _5, const 5_i32);
let mut v = (1,);

View File

@ -7,7 +7,7 @@ fn main() {
// CHECK: debug y => [[y:_.*]];
// CHECK: [[x]] = const 42_i32;
// CHECK: [[x]] = const 99_i32;
// CHECK: [[y]] = [[x]];
// CHECK: [[y]] = copy [[x]];
let mut x = 42;
x = 99;
let y = x;

View File

@ -8,7 +8,7 @@ fn main() {
// CHECK: debug y => [[y:_.*]];
// CHECK: [[x]] = const (42_i32, 43_i32);
// CHECK: ([[x]].1: i32) = const 99_i32;
// CHECK: [[y]] = [[x]];
// CHECK: [[y]] = copy [[x]];
let mut x = (42, 43);
x.1 = 99;
let y = x;

View File

@ -10,7 +10,7 @@ fn main() {
// CHECK: [[x]] = const (42_i32, 43_i32);
// CHECK: [[z]] = &mut [[x]];
// CHECK: ((*[[z]]).1: i32) = const 99_i32;
// CHECK: [[y]] = [[x]];
// CHECK: [[y]] = copy [[x]];
let mut x = (42, 43);
let z = &mut x;
z.1 = 99;

View File

@ -9,7 +9,7 @@ fn main() {
// CHECK: [[x]] = foo()
// CHECK: ([[x]].1: i32) = const 99_i32;
// CHECK: ([[x]].0: i32) = const 42_i32;
// CHECK: [[y]] = ([[x]].1: i32);
// CHECK: [[y]] = copy ([[x]].1: i32);
let mut x: (i32, i32) = foo();
x.1 = 99;
x.0 = 42;

View File

@ -9,9 +9,9 @@ fn main() {
// CHECK: debug x => [[x:_.*]];
// CHECK: debug y => [[y:_.*]];
// CHECK: [[x]] = const 42_u32;
// CHECK: [[tmp:_.*]] = (*{{_.*}});
// CHECK: [[tmp:_.*]] = copy (*{{_.*}});
// CHECK: [[x]] = move [[tmp]];
// CHECK: [[y]] = [[x]];
// CHECK: [[y]] = copy [[x]];
let mut x = 42;
unsafe {
x = STATIC;

View File

@ -11,9 +11,9 @@ fn main() {
// CHECK: debug z => [[z:_.*]];
// CHECK: [[a]] = foo()
// CHECK: [[x]] = const (1_i32, 2_i32);
// CHECK: ([[x]].1: i32) = [[a]];
// CHECK: [[y]] = ([[x]].1: i32);
// CHECK: [[z]] = ([[x]].0: i32);
// CHECK: ([[x]].1: i32) = copy [[a]];
// CHECK: [[y]] = copy ([[x]].1: i32);
// CHECK: [[z]] = copy ([[x]].0: i32);
let a = foo();
let mut x: (i32, i32) = (1, 2);
x.1 = a;

View File

@ -15,7 +15,7 @@ fn size_of<T>() -> usize {
// CHECK-LABEL: fn size_of(
// CHECK: _1 = const 0_usize;
// CHECK-NEXT: _1 = const SizeOfConst::<T>::SIZE;
// CHECK-NEXT: _0 = _1;
// CHECK-NEXT: _0 = copy _1;
let mut a = 0;
a = SizeOfConst::<T>::SIZE;
a

View File

@ -10,7 +10,7 @@ fn main() {
// CHECK: [[ptr:_.*]] = const main::FOO;
// CHECK: [[ref:_.*]] = &raw const (*[[ptr]]);
// CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeProvenance);
// CHECK: = read([[x]])
// CHECK: = read(copy [[x]])
const FOO: &i32 = &1;
let x = FOO as *const i32 as usize;
read(x);

View File

@ -7,7 +7,7 @@
fn main() {
// CHECK-LABEL: fn main(
// CHECK: debug a => [[a:_.*]];
// CHECK: [[slice:_.*]] = {{.*}} as &[u32] (PointerCoercion(Unsize));
// CHECK: [[slice:_.*]] = copy {{.*}} as &[u32] (PointerCoercion(Unsize));
// CHECK: assert(const true,
// CHECK: [[a]] = const 2_u32;
let a = (&[1u32, 2, 3] as &[u32])[1];

View File

@ -21,11 +21,11 @@ fn compare_address() -> bool {
// CHECK: bb0: {
// CHECK-NEXT: _1 = const 5_u8;
// CHECK-NEXT: _2 = &_1;
// CHECK-NEXT: _3 = _1;
// CHECK-NEXT: _3 = copy _1;
// CHECK-NEXT: _4 = &_3;
// CHECK-NEXT: _0 = cmp_ref(_2, _4)
// CHECK-NEXT: _0 = cmp_ref(copy _2, copy _4)
// CHECK: bb1: {
// CHECK-NEXT: _0 = opaque::<u8>(_3)
// CHECK-NEXT: _0 = opaque::<u8>(copy _3)
mir! {
{
let a = 5_u8;
@ -51,9 +51,9 @@ fn borrowed<T: Copy + Freeze>(x: T) -> bool {
// CHECK-LABEL: fn borrowed(
// CHECK: bb0: {
// CHECK-NEXT: _3 = &_1;
// CHECK-NEXT: _0 = opaque::<&T>(_3)
// CHECK-NEXT: _0 = opaque::<&T>(copy _3)
// CHECK: bb1: {
// CHECK-NEXT: _0 = opaque::<T>(_1)
// CHECK-NEXT: _0 = opaque::<T>(copy _1)
mir! {
{
let a = x;
@ -74,11 +74,11 @@ fn borrowed<T: Copy + Freeze>(x: T) -> bool {
fn non_freeze<T: Copy>(x: T) -> bool {
// CHECK-LABEL: fn non_freeze(
// CHECK: bb0: {
// CHECK-NEXT: _2 = _1;
// CHECK-NEXT: _2 = copy _1;
// CHECK-NEXT: _3 = &_1;
// CHECK-NEXT: _0 = opaque::<&T>(_3)
// CHECK-NEXT: _0 = opaque::<&T>(copy _3)
// CHECK: bb1: {
// CHECK-NEXT: _0 = opaque::<T>(_2)
// CHECK-NEXT: _0 = opaque::<T>(copy _2)
mir! {
{
let a = x;

View File

@ -16,6 +16,6 @@ fn main() {
// CHECK: {{_.*}} = const 4_usize;
// CHECK: {{_.*}} = const true;
// CHECK: assert(const true
// CHECK: [[x]] = [[array_lit]][2 of 3];
// CHECK: [[x]] = copy [[array_lit]][2 of 3];
let x: u32 = [0, 1, 2, 3][2];
}

View File

@ -73,7 +73,7 @@ fn statics() {
static RC: &E = &E::V2(4);
// CHECK: [[t:_.*]] = const {alloc5: &&E};
// CHECK: [[e2]] = (*[[t]]);
// CHECK: [[e2]] = copy (*[[t]]);
let e2 = RC;
// CHECK: switchInt({{move _.*}}) -> {{.*}}
@ -108,7 +108,7 @@ fn mutate_discriminant() -> u8 {
// CHECK: [[a:_.*]] = discriminant({{_.*}});
let a = Discriminant(x);
// CHECK: switchInt([[a]]) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
// CHECK: switchInt(copy [[a]]) -> [0: {{bb.*}}, otherwise: {{bb.*}}];
match a {
0 => bb1,
_ => bad,
@ -143,8 +143,8 @@ fn multiple(x: bool, i: u8) {
// discriminant(e) => Top
// (e as Some).0 => Top
// CHECK: [[x2]] = const 0_u8;
// CHECK: [[some:_.*]] = (({{_.*}} as Some).0: u8)
// CHECK: [[x2]] = [[some]];
// CHECK: [[some:_.*]] = copy (({{_.*}} as Some).0: u8)
// CHECK: [[x2]] = copy [[some]];
let x2 = match e {
Some(i) => i,
None => 0,
@ -153,7 +153,7 @@ fn multiple(x: bool, i: u8) {
// Therefore, `x2` should be `Top` here, and no replacement shall happen.
// CHECK-NOT: [[y]] = const
// CHECK: [[y]] = [[x2]];
// CHECK: [[y]] = copy [[x2]];
// CHECK-NOT: [[y]] = const
let y = x2;
}

View File

@ -13,6 +13,6 @@ fn main() {
// CHECK: {{_.*}} = const 5000_usize;
// CHECK: {{_.*}} = const true;
// CHECK: assert(const true
// CHECK: [[x]] = [[array_lit]][2 of 3];
// CHECK: [[x]] = copy [[array_lit]][2 of 3];
let x: u8 = [0_u8; 5000][2];
}

View File

@ -24,7 +24,7 @@ fn main() {
// This should currently not be propagated.
// CHECK-NOT: [[b]] = const
// CHECK: [[b]] = [[a]];
// CHECK: [[b]] = copy [[a]];
// CHECK-NOT: [[b]] = const
let b = a;
}

View File

@ -14,8 +14,8 @@ fn main() {
// CHECK: {{_.*}} = const true;
// CHECK: assert(const true
// CHECK-NOT: [[t:_.*]] = [[array_lit]][_
// CHECK: [[t:_.*]] = [[array_lit]][2 of 3];
// CHECK-NOT: [[t:_.*]] = {{copy|move}} [[array_lit]][_
// CHECK: [[t:_.*]] = copy [[array_lit]][2 of 3];
// CHECK: [[x]] = Add(move [[t]], const 0_u32);
let x: u32 = [42; 8][2] + 0;
}

View File

@ -20,6 +20,6 @@ fn main() {
*p.add(1) = 1;
}
// CHECK: [[x1]] = ({{_.*}}.1: u8);
// CHECK: [[x1]] = copy ({{_.*}}.1: u8);
let x1 = x.1; // should not be propagated
}

View File

@ -17,7 +17,7 @@ fn main() {
// CHECK: {{_.*}} = const true;
// CHECK: assert(const true,
// CHECK: [[local]] = (*{{_.*}})[1 of 2];
// CHECK: [[local]] = copy (*{{_.*}})[1 of 2];
let local = (&[1u32, 2, 3] as &[u32])[1];
// CHECK-NOT: {{_.*}} = Len(
@ -28,7 +28,7 @@ fn main() {
// CHECK: {{_.*}} = const true;
// CHECK: assert(const true,
// CHECK-NOT: [[constant]] = (*{{_.*}})[_
// CHECK: [[constant]] = (*{{_.*}})[1 of 2];
// CHECK-NOT: [[constant]] = {{copy|move}} (*{{_.*}})[_
// CHECK: [[constant]] = copy (*{{_.*}})[1 of 2];
let constant = SLICE[1];
}

View File

@ -46,15 +46,15 @@ fn main() {
const SMALL_VAL: SmallStruct = SmallStruct(4., Some(S(1)), &[]);
// CHECK: [[a1]] = const 4f32;
// CHECK: [[b1]] = ({{_.*}}.1: std::option::Option<S>);
// CHECK: [[c1]] = ({{_.*}}.2: &[f32]);
// CHECK: [[b1]] = copy ({{_.*}}.1: std::option::Option<S>);
// CHECK: [[c1]] = copy ({{_.*}}.2: &[f32]);
let SmallStruct(a1, b1, c1) = SMALL_VAL;
static SMALL_STAT: &SmallStruct = &SmallStruct(9., None, &[13.]);
// CHECK: [[a2]] = const 9f32;
// CHECK: [[b2]] = ((*{{_.*}}).1: std::option::Option<S>);
// CHECK: [[c2]] = ((*{{_.*}}).2: &[f32]);
// CHECK: [[b2]] = copy ((*{{_.*}}).1: std::option::Option<S>);
// CHECK: [[c2]] = copy ((*{{_.*}}).2: &[f32]);
let SmallStruct(a2, b2, c2) = *SMALL_STAT;
// CHECK: [[ss]] = SmallStruct(const 9f32, move {{_.*}}, move {{_.*}});
@ -63,14 +63,14 @@ fn main() {
const BIG_VAL: BigStruct = BigStruct(25., None, &[]);
// CHECK: [[a3]] = const 25f32;
// CHECK: [[b3]] = ({{_.*}}.1: std::option::Option<S>);
// CHECK: [[c3]] = ({{_.*}}.2: &[f32]);
// CHECK: [[b3]] = copy ({{_.*}}.1: std::option::Option<S>);
// CHECK: [[c3]] = copy ({{_.*}}.2: &[f32]);
let BigStruct(a3, b3, c3) = BIG_VAL;
static BIG_STAT: &BigStruct = &BigStruct(82., Some(S(35)), &[45., 72.]);
// CHECK: [[a4]] = const 82f32;
// CHECK: [[b4]] = ((*{{_.*}}).1: std::option::Option<S>);
// CHECK: [[c4]] = ((*{{_.*}}).2: &[f32]);
// CHECK: [[b4]] = copy ((*{{_.*}}).1: std::option::Option<S>);
// CHECK: [[c4]] = copy ((*{{_.*}}).2: &[f32]);
let BigStruct(a4, b4, c4) = *BIG_STAT;
// We arbitrarily limit the size of synthetized values to 4 pointers.

View File

@ -14,7 +14,7 @@ fn use_both(_: i32, _: i32) {}
// EMIT_MIR call_arg_copy.move_simple.DeadStoreElimination-final.diff
fn move_simple(x: i32) {
// CHECK-LABEL: fn move_simple(
// CHECK: = use_both(_1, move _1)
// CHECK: = use_both(copy _1, move _1)
use_both(x, x);
}
@ -28,7 +28,7 @@ struct Packed {
#[custom_mir(dialect = "analysis")]
fn move_packed(packed: Packed) {
// CHECK-LABEL: fn move_packed(
// CHECK: = use_both(const 0_i32, (_1.1: i32))
// CHECK: = use_both(const 0_i32, copy (_1.1: i32))
mir! {
{
// We have a packed struct, verify that the copy is not turned into a move.

View File

@ -41,9 +41,9 @@ fn arg_src(mut x: i32) -> i32 {
// CHECK-LABEL: fn arg_src(
// CHECK: debug x => [[x:_.*]];
// CHECK: debug y => [[y:_.*]];
// CHECK: [[y]] = [[x]]
// CHECK: [[y]] = copy [[x]]
// CHECK: [[x]] = const 123_i32;
// CHECK-NOT: {{_.*}} = [[y]];
// CHECK-NOT: {{_.*}} = copy [[y]];
let y = x;
x = 123; // Don't propagate this assignment to `y`
y

View File

@ -10,7 +10,7 @@ fn f(mut a: usize) -> usize {
// CHECK-LABEL: fn f(
// CHECK: debug a => [[a:_.*]];
// CHECK: debug b => [[b:_.*]];
// CHECK: [[b]] = [[a]];
// CHECK: [[b]] = copy [[a]];
// CHECK: [[a]] = const 5_usize;
// CHECK: [[a]] = move [[b]];
// CHECK: id::<usize>(move [[a]])

View File

@ -14,7 +14,7 @@ pub fn f(mut a: usize) -> usize {
// CHECK-LABEL: fn f(
// CHECK: debug a => [[a:_.*]];
// CHECK: debug b => [[b:_.*]];
// CHECK: [[b]] = [[a]];
// CHECK: [[b]] = copy [[a]];
// CHECK: [[a]] = const 5_usize;
// CHECK: [[a]] = move [[b]];
// CHECK: id::<usize>(move [[a]])

View File

@ -7,9 +7,9 @@
// CHECK: debug init => [[init:_.*]];
// CHECK: debug buf => [[buf:_.*]];
// CHECK: [[buf]] = [const 0_u8; 1024];
// CHECK-NOT: {{_.*}} = [[init]];
// CHECK-NOT: {{_.*}} = copy [[init]];
// CHECK: move [[init]](move {{_.*}})
// CHECK: {{_.*}} = [[buf]]
// CHECK: {{_.*}} = copy [[buf]]
let mut buf = [0; 1024];
init(&mut buf);
buf

View File

@ -49,7 +49,7 @@ fn opt3(x: Option2<u32>, y: Option2<bool>) -> u32 {
// CHECK: bb0: {
// CHECK: [[LOCAL1:_.*]] = discriminant({{.*}});
// CHECK: [[LOCAL2:_.*]] = discriminant({{.*}});
// CHECK: [[CMP_LOCAL]] = Ne([[LOCAL1]], move [[LOCAL2]]);
// CHECK: [[CMP_LOCAL]] = Ne(copy [[LOCAL1]], move [[LOCAL2]]);
// CHECK: switchInt(move [[CMP_LOCAL]]) -> [
// CHECK-NEXT: }
match (x, y) {
@ -67,7 +67,7 @@ fn opt4(x: Option2<u32>, y: Option2<u32>) -> u32 {
// CHECK: bb0: {
// CHECK: [[LOCAL1:_.*]] = discriminant({{.*}});
// CHECK: [[LOCAL2:_.*]] = discriminant({{.*}});
// CHECK: [[CMP_LOCAL]] = Ne([[LOCAL1]], move [[LOCAL2]]);
// CHECK: [[CMP_LOCAL]] = Ne(copy [[LOCAL1]], move [[LOCAL2]]);
// CHECK: switchInt(move [[CMP_LOCAL]]) -> [
// CHECK-NEXT: }
match (x, y) {

View File

@ -32,7 +32,7 @@ fn opt2(x: Option2<u32>, y: Option2<u32>, z: Option2<u32>) -> u32 {
// CHECK: bb0: {
// CHECK: [[LOCAL1:_.*]] = discriminant({{.*}});
// CHECK: [[LOCAL2:_.*]] = discriminant({{.*}});
// CHECK: [[CMP_LOCAL]] = Ne([[LOCAL1]], move [[LOCAL2]]);
// CHECK: [[CMP_LOCAL]] = Ne(copy [[LOCAL1]], move [[LOCAL2]]);
// CHECK: switchInt(move [[CMP_LOCAL]]) -> [
// CHECK-NEXT: }
match (x, y, z) {

View File

@ -21,91 +21,91 @@
fn subexpression_elimination(x: u64, y: u64, mut z: u64) {
// CHECK-LABEL: fn subexpression_elimination(
// CHECK: [[add:_.*]] = Add(_1, _2);
// CHECK: opaque::<u64>([[add]])
// CHECK: [[add:_.*]] = Add(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[add]])
opaque(x + y);
// CHECK: [[mul:_.*]] = Mul(_1, _2);
// CHECK: opaque::<u64>([[mul]])
// CHECK: [[mul:_.*]] = Mul(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[mul]])
opaque(x * y);
// CHECK: [[sub:_.*]] = Sub(_1, _2);
// CHECK: opaque::<u64>([[sub]])
// CHECK: [[sub:_.*]] = Sub(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[sub]])
opaque(x - y);
// CHECK: [[div:_.*]] = Div(_1, _2);
// CHECK: opaque::<u64>([[div]])
// CHECK: [[div:_.*]] = Div(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[div]])
opaque(x / y);
// CHECK: [[rem:_.*]] = Rem(_1, _2);
// CHECK: opaque::<u64>([[rem]])
// CHECK: [[rem:_.*]] = Rem(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[rem]])
opaque(x % y);
// CHECK: [[and:_.*]] = BitAnd(_1, _2);
// CHECK: opaque::<u64>([[and]])
// CHECK: [[and:_.*]] = BitAnd(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[and]])
opaque(x & y);
// CHECK: [[or:_.*]] = BitOr(_1, _2);
// CHECK: opaque::<u64>([[or]])
// CHECK: [[or:_.*]] = BitOr(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[or]])
opaque(x | y);
// CHECK: [[xor:_.*]] = BitXor(_1, _2);
// CHECK: opaque::<u64>([[xor]])
// CHECK: [[xor:_.*]] = BitXor(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[xor]])
opaque(x ^ y);
// CHECK: [[shl:_.*]] = Shl(_1, _2);
// CHECK: opaque::<u64>([[shl]])
// CHECK: [[shl:_.*]] = Shl(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[shl]])
opaque(x << y);
// CHECK: [[shr:_.*]] = Shr(_1, _2);
// CHECK: opaque::<u64>([[shr]])
// CHECK: [[shr:_.*]] = Shr(copy _1, copy _2);
// CHECK: opaque::<u64>(copy [[shr]])
opaque(x >> y);
// CHECK: [[int:_.*]] = _1 as u32 (IntToInt);
// CHECK: opaque::<u32>([[int]])
// CHECK: [[int:_.*]] = copy _1 as u32 (IntToInt);
// CHECK: opaque::<u32>(copy [[int]])
opaque(x as u32);
// CHECK: [[float:_.*]] = _1 as f32 (IntToFloat);
// CHECK: opaque::<f32>([[float]])
// CHECK: [[float:_.*]] = copy _1 as f32 (IntToFloat);
// CHECK: opaque::<f32>(copy [[float]])
opaque(x as f32);
// CHECK: [[wrap:_.*]] = S::<u64>(_1);
// CHECK: opaque::<S<u64>>([[wrap]])
// CHECK: [[wrap:_.*]] = S::<u64>(copy _1);
// CHECK: opaque::<S<u64>>(copy [[wrap]])
opaque(S(x));
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(S(x).0);
// Those are duplicates to substitute somehow.
// CHECK: opaque::<u64>([[add]])
// CHECK: opaque::<u64>(copy [[add]])
opaque(x + y);
// CHECK: opaque::<u64>([[mul]])
// CHECK: opaque::<u64>(copy [[mul]])
opaque(x * y);
// CHECK: opaque::<u64>([[sub]])
// CHECK: opaque::<u64>(copy [[sub]])
opaque(x - y);
// CHECK: opaque::<u64>([[div]])
// CHECK: opaque::<u64>(copy [[div]])
opaque(x / y);
// CHECK: opaque::<u64>([[rem]])
// CHECK: opaque::<u64>(copy [[rem]])
opaque(x % y);
// CHECK: opaque::<u64>([[and]])
// CHECK: opaque::<u64>(copy [[and]])
opaque(x & y);
// CHECK: opaque::<u64>([[or]])
// CHECK: opaque::<u64>(copy [[or]])
opaque(x | y);
// CHECK: opaque::<u64>([[xor]])
// CHECK: opaque::<u64>(copy [[xor]])
opaque(x ^ y);
// CHECK: opaque::<u64>([[shl]])
// CHECK: opaque::<u64>(copy [[shl]])
opaque(x << y);
// CHECK: opaque::<u64>([[shr]])
// CHECK: opaque::<u64>(copy [[shr]])
opaque(x >> y);
// CHECK: opaque::<u32>([[int]])
// CHECK: opaque::<u32>(copy [[int]])
opaque(x as u32);
// CHECK: opaque::<f32>([[float]])
// CHECK: opaque::<f32>(copy [[float]])
opaque(x as f32);
// CHECK: opaque::<S<u64>>([[wrap]])
// CHECK: opaque::<S<u64>>(copy [[wrap]])
opaque(S(x));
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(S(x).0);
// We can substitute through a complex expression.
// CHECK: [[compound:_.*]] = Sub([[mul]], _2);
// CHECK: opaque::<u64>([[compound]])
// CHECK: opaque::<u64>([[compound]])
// CHECK: [[compound:_.*]] = Sub(copy [[mul]], copy _2);
// CHECK: opaque::<u64>(copy [[compound]])
// CHECK: opaque::<u64>(copy [[compound]])
opaque((x * y) - y);
opaque((x * y) - y);
// We can substitute through an immutable reference too.
// CHECK: [[ref:_.*]] = &_3;
// CHECK: [[deref:_.*]] = (*[[ref]]);
// CHECK: [[addref:_.*]] = Add([[deref]], _1);
// CHECK: opaque::<u64>([[addref]])
// CHECK: opaque::<u64>([[addref]])
// CHECK: [[deref:_.*]] = copy (*[[ref]]);
// CHECK: [[addref:_.*]] = Add(copy [[deref]], copy _1);
// CHECK: opaque::<u64>(copy [[addref]])
// CHECK: opaque::<u64>(copy [[addref]])
let a = &z;
opaque(*a + x);
opaque(*a + x);
@ -141,10 +141,10 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) {
// We can substitute again, but not with the earlier computations.
// Important: `e` is not `a`!
// CHECK: [[ref2:_.*]] = &_3;
// CHECK: [[deref2:_.*]] = (*[[ref2]]);
// CHECK: [[addref2:_.*]] = Add([[deref2]], _1);
// CHECK: opaque::<u64>([[addref2]])
// CHECK: opaque::<u64>([[addref2]])
// CHECK: [[deref2:_.*]] = copy (*[[ref2]]);
// CHECK: [[addref2:_.*]] = Add(copy [[deref2]], copy _1);
// CHECK: opaque::<u64>(copy [[addref2]])
// CHECK: opaque::<u64>(copy [[addref2]])
let e = &z;
opaque(*e + x);
opaque(*e + x);
@ -152,9 +152,9 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) {
fn wrap_unwrap<T: Copy>(x: T) -> T {
// CHECK-LABEL: fn wrap_unwrap(
// CHECK: [[some:_.*]] = Option::<T>::Some(_1);
// CHECK: [[some:_.*]] = Option::<T>::Some(copy _1);
// CHECK: switchInt(const 1_isize)
// CHECK: _0 = _1;
// CHECK: _0 = copy _1;
match Some(x) {
Some(y) => y,
None => panic!(),
@ -163,35 +163,35 @@ fn wrap_unwrap<T: Copy>(x: T) -> T {
fn repeated_index<T: Copy, const N: usize>(x: T, idx: usize) {
// CHECK-LABEL: fn repeated_index(
// CHECK: [[a:_.*]] = [_1; N];
// CHECK: [[a:_.*]] = [copy _1; N];
let a = [x; N];
// CHECK: opaque::<T>(_1)
// CHECK: opaque::<T>(copy _1)
opaque(a[0]);
// CHECK: opaque::<T>(_1)
// CHECK: opaque::<T>(copy _1)
opaque(a[idx]);
}
fn unary(x: i64) {
// CHECK-LABEL: fn unary(
// CHECK: opaque::<i64>(_1)
// CHECK: opaque::<i64>(copy _1)
opaque(--x); // This is `x`.
// CHECK: [[b:_.*]] = Lt(_1, const 13_i64);
// CHECK: opaque::<bool>([[b]])
// CHECK: [[b:_.*]] = Lt(copy _1, const 13_i64);
// CHECK: opaque::<bool>(copy [[b]])
let b = x < 13;
opaque(!!b); // This is `b`.
// Both lines should test the same thing.
// CHECK: [[c:_.*]] = Ne(_1, const 15_i64);
// CHECK: opaque::<bool>([[c]])
// CHECK: opaque::<bool>([[c]])
// CHECK: [[c:_.*]] = Ne(copy _1, const 15_i64);
// CHECK: opaque::<bool>(copy [[c]])
// CHECK: opaque::<bool>(copy [[c]])
opaque(x != 15);
opaque(!(x == 15));
// Both lines should test the same thing.
// CHECK: [[d:_.*]] = Eq(_1, const 35_i64);
// CHECK: opaque::<bool>([[d]])
// CHECK: opaque::<bool>([[d]])
// CHECK: [[d:_.*]] = Eq(copy _1, const 35_i64);
// CHECK: opaque::<bool>(copy [[d]])
// CHECK: opaque::<bool>(copy [[d]])
opaque(x == 35);
opaque(!(x != 35));
}
@ -199,53 +199,53 @@ fn unary(x: i64) {
/// Verify symbolic integer arithmetic simplifications.
fn arithmetic(x: u64) {
// CHECK-LABEL: fn arithmetic(
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x + 0);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x - 0);
// CHECK: opaque::<u64>(const 0_u64)
opaque(x - x);
// CHECK: opaque::<u64>(const 0_u64)
opaque(x * 0);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x * 1);
// CHECK: assert(!const true, "attempt to divide `{}` by zero",
// CHECK: [[div0:_.*]] = Div(_1, const 0_u64);
// CHECK: [[div0:_.*]] = Div(copy _1, const 0_u64);
// CHECK: opaque::<u64>(move [[div0]])
opaque(x / 0);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x / 1);
// CHECK: opaque::<u64>(const 0_u64)
opaque(0 / x);
// CHECK: [[odiv:_.*]] = Div(const 1_u64, _1);
// CHECK: [[odiv:_.*]] = Div(const 1_u64, copy _1);
// CHECK: opaque::<u64>(move [[odiv]])
opaque(1 / x);
// CHECK: assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero"
// CHECK: [[rem0:_.*]] = Rem(_1, const 0_u64);
// CHECK: [[rem0:_.*]] = Rem(copy _1, const 0_u64);
// CHECK: opaque::<u64>(move [[rem0]])
opaque(x % 0);
// CHECK: opaque::<u64>(const 0_u64)
opaque(x % 1);
// CHECK: opaque::<u64>(const 0_u64)
opaque(0 % x);
// CHECK: [[orem:_.*]] = Rem(const 1_u64, _1);
// CHECK: [[orem:_.*]] = Rem(const 1_u64, copy _1);
// CHECK: opaque::<u64>(move [[orem]])
opaque(1 % x);
// CHECK: opaque::<u64>(const 0_u64)
opaque(x & 0);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x & u64::MAX);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x | 0);
// CHECK: opaque::<u64>(const u64::MAX)
opaque(x | u64::MAX);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x ^ 0);
// CHECK: opaque::<u64>(const 0_u64)
opaque(x ^ x);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x >> 0);
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x << 0);
}
@ -255,10 +255,10 @@ fn comparison(x: u64, y: u64) {
opaque(x == x);
// CHECK: opaque::<bool>(const false)
opaque(x != x);
// CHECK: [[eqxy:_.*]] = Eq(_1, _2);
// CHECK: [[eqxy:_.*]] = Eq(copy _1, copy _2);
// CHECK: opaque::<bool>(move [[eqxy]])
opaque(x == y);
// CHECK: [[nexy:_.*]] = Ne(_1, _2);
// CHECK: [[nexy:_.*]] = Ne(copy _1, copy _2);
// CHECK: opaque::<bool>(move [[nexy]])
opaque(x != y);
}
@ -268,10 +268,10 @@ fn comparison(x: u64, y: u64) {
fn arithmetic_checked(x: u64) {
// CHECK-LABEL: fn arithmetic_checked(
// CHECK: assert(!const false,
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x + 0);
// CHECK: assert(!const false,
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x - 0);
// CHECK: assert(!const false,
// CHECK: opaque::<u64>(const 0_u64)
@ -280,39 +280,39 @@ fn arithmetic_checked(x: u64) {
// CHECK: opaque::<u64>(const 0_u64)
opaque(x * 0);
// CHECK: assert(!const false,
// CHECK: opaque::<u64>(_1)
// CHECK: opaque::<u64>(copy _1)
opaque(x * 1);
}
/// Verify that we do not apply arithmetic simplifications on floats.
fn arithmetic_float(x: f64) {
// CHECK-LABEL: fn arithmetic_float(
// CHECK: [[add:_.*]] = Add(_1, const 0f64);
// CHECK: [[add:_.*]] = Add(copy _1, const 0f64);
// CHECK: opaque::<f64>(move [[add]])
opaque(x + 0.);
// CHECK: [[sub:_.*]] = Sub(_1, const 0f64);
// CHECK: [[sub:_.*]] = Sub(copy _1, const 0f64);
// CHECK: opaque::<f64>(move [[sub]])
opaque(x - 0.);
// CHECK: [[mul:_.*]] = Mul(_1, const 0f64);
// CHECK: [[mul:_.*]] = Mul(copy _1, const 0f64);
// CHECK: opaque::<f64>(move [[mul]])
opaque(x * 0.);
// CHECK: [[div0:_.*]] = Div(_1, const 0f64);
// CHECK: [[div0:_.*]] = Div(copy _1, const 0f64);
// CHECK: opaque::<f64>(move [[div0]])
opaque(x / 0.);
// CHECK: [[zdiv:_.*]] = Div(const 0f64, _1);
// CHECK: [[zdiv:_.*]] = Div(const 0f64, copy _1);
// CHECK: opaque::<f64>(move [[zdiv]])
opaque(0. / x);
// CHECK: [[rem0:_.*]] = Rem(_1, const 0f64);
// CHECK: [[rem0:_.*]] = Rem(copy _1, const 0f64);
// CHECK: opaque::<f64>(move [[rem0]])
opaque(x % 0.);
// CHECK: [[zrem:_.*]] = Rem(const 0f64, _1);
// CHECK: [[zrem:_.*]] = Rem(const 0f64, copy _1);
// CHECK: opaque::<f64>(move [[zrem]])
opaque(0. % x);
// Those are not simplifiable to `true`/`false`, thanks to NaNs.
// CHECK: [[eq:_.*]] = Eq(_1, _1);
// CHECK: [[eq:_.*]] = Eq(copy _1, copy _1);
// CHECK: opaque::<bool>(move [[eq]])
opaque(x == x);
// CHECK: [[ne:_.*]] = Ne(_1, _1);
// CHECK: [[ne:_.*]] = Ne(copy _1, copy _1);
// CHECK: opaque::<bool>(move [[ne]])
opaque(x != x);
}
@ -386,36 +386,36 @@ fn cast() {
fn multiple_branches(t: bool, x: u8, y: u8) {
// CHECK-LABEL: fn multiple_branches(
// CHECK: switchInt(_1) -> [0: [[bbf:bb.*]], otherwise: [[bbt:bb.*]]];
// CHECK: switchInt(copy _1) -> [0: [[bbf:bb.*]], otherwise: [[bbt:bb.*]]];
if t {
// CHECK: [[bbt]]: {
// CHECK: [[a:_.*]] = Add(_2, _3);
// CHECK: opaque::<u8>([[a]])
// CHECK: opaque::<u8>([[a]])
// CHECK: [[a:_.*]] = Add(copy _2, copy _3);
// CHECK: opaque::<u8>(copy [[a]])
// CHECK: opaque::<u8>(copy [[a]])
// CHECK: goto -> [[bbc:bb.*]];
opaque(x + y);
opaque(x + y);
} else {
// CHECK: [[bbf]]: {
// CHECK: [[b:_.*]] = Add(_2, _3);
// CHECK: opaque::<u8>([[b]])
// CHECK: opaque::<u8>([[b]])
// CHECK: [[b:_.*]] = Add(copy _2, copy _3);
// CHECK: opaque::<u8>(copy [[b]])
// CHECK: opaque::<u8>(copy [[b]])
// CHECK: goto -> [[bbc:bb.*]];
opaque(x + y);
opaque(x + y);
}
// Neither `a` nor `b` dominate `c`, so we cannot reuse any of them.
// CHECK: [[bbc]]: {
// CHECK: [[c:_.*]] = Add(_2, _3);
// CHECK: opaque::<u8>([[c]])
// CHECK: [[c:_.*]] = Add(copy _2, copy _3);
// CHECK: opaque::<u8>(copy [[c]])
opaque(x + y);
// `c` dominates both calls, so we can reuse it.
if t {
// CHECK: opaque::<u8>([[c]])
// CHECK: opaque::<u8>(copy [[c]])
opaque(x + y);
} else {
// CHECK: opaque::<u8>([[c]])
// CHECK: opaque::<u8>(copy [[c]])
opaque(x + y);
}
}
@ -469,18 +469,18 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) {
// CHECK-LABEL: fn dereferences(
// Do not reuse dereferences of `&mut`.
// CHECK: [[st1:_.*]] = (*_1);
// CHECK: [[st1:_.*]] = copy (*_1);
// CHECK: opaque::<u32>(move [[st1]])
// CHECK: [[st2:_.*]] = (*_1);
// CHECK: [[st2:_.*]] = copy (*_1);
// CHECK: opaque::<u32>(move [[st2]])
opaque(*t);
opaque(*t);
// Do not reuse dereferences of `*const`.
// CHECK: [[raw:_.*]] = &raw const (*_1);
// CHECK: [[st3:_.*]] = (*[[raw]]);
// CHECK: [[st3:_.*]] = copy (*[[raw]]);
// CHECK: opaque::<u32>(move [[st3]])
// CHECK: [[st4:_.*]] = (*[[raw]]);
// CHECK: [[st4:_.*]] = copy (*[[raw]]);
// CHECK: opaque::<u32>(move [[st4]])
let z = &raw const *t;
unsafe { opaque(*z) };
@ -488,9 +488,9 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) {
// Do not reuse dereferences of `*mut`.
// CHECK: [[ptr:_.*]] = &raw mut (*_1);
// CHECK: [[st5:_.*]] = (*[[ptr]]);
// CHECK: [[st5:_.*]] = copy (*[[ptr]]);
// CHECK: opaque::<u32>(move [[st5]])
// CHECK: [[st6:_.*]] = (*[[ptr]]);
// CHECK: [[st6:_.*]] = copy (*[[ptr]]);
// CHECK: opaque::<u32>(move [[st6]])
let z = &raw mut *t;
unsafe { opaque(*z) };
@ -498,9 +498,9 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) {
// We can reuse dereferences of `&Freeze`.
// CHECK: [[ref:_.*]] = &(*_1);
// CHECK: [[st7:_.*]] = (*[[ref]]);
// CHECK: opaque::<u32>([[st7]])
// CHECK: opaque::<u32>([[st7]])
// CHECK: [[st7:_.*]] = copy (*[[ref]]);
// CHECK: opaque::<u32>(copy [[st7]])
// CHECK: opaque::<u32>(copy [[st7]])
let z = &*t;
opaque(*z);
opaque(*z);
@ -510,17 +510,17 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) {
opaque(&*z);
// `*u` is not Freeze, so we cannot reuse.
// CHECK: [[st8:_.*]] = (*_2);
// CHECK: [[st8:_.*]] = copy (*_2);
// CHECK: opaque::<impl Copy>(move [[st8]])
// CHECK: [[st9:_.*]] = (*_2);
// CHECK: [[st9:_.*]] = copy (*_2);
// CHECK: opaque::<impl Copy>(move [[st9]])
opaque(*u);
opaque(*u);
// `*s` is not Copy, by `(*s).0` is, so we can reuse.
// CHECK: [[st10:_.*]] = ((*_3).0: u32);
// CHECK: opaque::<u32>([[st10]])
// CHECK: opaque::<u32>([[st10]])
// `*s` is not Copy, but `(*s).0` is, so we can reuse.
// CHECK: [[st10:_.*]] = copy ((*_3).0: u32);
// CHECK: opaque::<u32>(copy [[st10]])
// CHECK: opaque::<u32>(copy [[st10]])
opaque(s.0);
opaque(s.0);
}
@ -551,38 +551,38 @@ fn duplicate_slice() -> (bool, bool) {
let d: &str;
{
// CHECK: [[a:_.*]] = (const "a",);
// CHECK: [[au:_.*]] = ([[a]].0: &str) as u128 (Transmute);
// CHECK: [[au:_.*]] = copy ([[a]].0: &str) as u128 (Transmute);
let a = ("a",);
Call(au = transmute::<_, u128>(a.0), ReturnTo(bb1), UnwindContinue())
}
bb1 = {
// CHECK: [[c:_.*]] = identity::<&str>(([[a]].0: &str))
// CHECK: [[c:_.*]] = identity::<&str>(copy ([[a]].0: &str))
Call(c = identity(a.0), ReturnTo(bb2), UnwindContinue())
}
bb2 = {
// CHECK: [[cu:_.*]] = [[c]] as u128 (Transmute);
// CHECK: [[cu:_.*]] = copy [[c]] as u128 (Transmute);
Call(cu = transmute::<_, u128>(c), ReturnTo(bb3), UnwindContinue())
}
bb3 = {
// This slice is different from `a.0`. Hence `bu` is not `au`.
// CHECK: [[b:_.*]] = const "a";
// CHECK: [[bu:_.*]] = [[b]] as u128 (Transmute);
// CHECK: [[bu:_.*]] = copy [[b]] as u128 (Transmute);
let b = "a";
Call(bu = transmute::<_, u128>(b), ReturnTo(bb4), UnwindContinue())
}
bb4 = {
// This returns a copy of `b`, which is not `a`.
// CHECK: [[d:_.*]] = identity::<&str>([[b]])
// CHECK: [[d:_.*]] = identity::<&str>(copy [[b]])
Call(d = identity(b), ReturnTo(bb5), UnwindContinue())
}
bb5 = {
// CHECK: [[du:_.*]] = [[d]] as u128 (Transmute);
// CHECK: [[du:_.*]] = copy [[d]] as u128 (Transmute);
Call(du = transmute::<_, u128>(d), ReturnTo(bb6), UnwindContinue())
}
bb6 = {
// `direct` must not fold to `true`, as `indirect` will not.
// CHECK: = Eq([[au]], [[bu]]);
// CHECK: = Eq([[cu]], [[du]]);
// CHECK: = Eq(copy [[au]], copy [[bu]]);
// CHECK: = Eq(copy [[cu]], copy [[du]]);
let direct = au == bu;
let indirect = cu == du;
RET = (direct, indirect);
@ -602,21 +602,21 @@ fn repeat() {
fn fn_pointers() {
// CHECK-LABEL: fn fn_pointers(
// CHECK: [[f:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer
// CHECK: opaque::<fn(u8) -> u8>([[f]])
// CHECK: opaque::<fn(u8) -> u8>(copy [[f]])
let f = identity as fn(u8) -> u8;
opaque(f);
// CHECK: [[g:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer
// CHECK: opaque::<fn(u8) -> u8>([[g]])
// CHECK: opaque::<fn(u8) -> u8>(copy [[g]])
let g = identity as fn(u8) -> u8;
opaque(g);
// CHECK: [[cf:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer
// CHECK: opaque::<fn()>([[cf]])
// CHECK: opaque::<fn()>(copy [[cf]])
let closure = || {};
let cf = closure as fn();
opaque(cf);
// CHECK: [[cg:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer
// CHECK: opaque::<fn()>([[cg]])
// CHECK: opaque::<fn()>(copy [[cg]])
let cg = closure as fn();
opaque(cg);
}
@ -642,9 +642,9 @@ fn constant_index_overflow<T: Copy>(x: &[T]) {
// CHECK: debug b => [[b:_.*]];
// CHECK: [[a]] = const usize::MAX;
// CHECK-NOT: = (*_1)[{{.*}} of 0];
// CHECK: [[b]] = (*_1)[[[a]]];
// CHECK: [[b]] = copy (*_1)[[[a]]];
// CHECK-NOT: = (*_1)[{{.*}} of 0];
// CHECK: [[b]] = (*_1)[0 of 1];
// CHECK: [[b]] = copy (*_1)[0 of 1];
// CHECK-NOT: = (*_1)[{{.*}} of 0];
let a = u64::MAX as usize;
let b = if a < x.len() { x[a] } else { x[0] };
@ -657,22 +657,22 @@ fn wide_ptr_provenance() {
let a: *const dyn Send = &1 as &dyn Send;
let b: *const dyn Send = &1 as &dyn Send;
// CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]);
// CHECK: [[eqp:_.*]] = Eq(copy [[a:_.*]], copy [[b:_.*]]);
// CHECK: opaque::<bool>(move [[eqp]])
opaque(a == b);
// CHECK: [[nep:_.*]] = Ne([[a]], [[b]]);
// CHECK: [[nep:_.*]] = Ne(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[nep]])
opaque(a != b);
// CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]);
// CHECK: [[ltp:_.*]] = Lt(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[ltp]])
opaque(a < b);
// CHECK: [[lep:_.*]] = Le([[a]], [[b]]);
// CHECK: [[lep:_.*]] = Le(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[lep]])
opaque(a <= b);
// CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]);
// CHECK: [[gtp:_.*]] = Gt(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[gtp]])
opaque(a > b);
// CHECK: [[gep:_.*]] = Ge([[a]], [[b]]);
// CHECK: [[gep:_.*]] = Ge(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[gep]])
opaque(a >= b);
}
@ -684,22 +684,22 @@ fn wide_ptr_same_provenance() {
let a: *const dyn Send = &slice[0] as &dyn Send;
let b: *const dyn Send = &slice[1] as &dyn Send;
// CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]);
// CHECK: [[eqp:_.*]] = Eq(copy [[a:_.*]], copy [[b:_.*]]);
// CHECK: opaque::<bool>(move [[eqp]])
opaque(a == b);
// CHECK: [[nep:_.*]] = Ne([[a]], [[b]]);
// CHECK: [[nep:_.*]] = Ne(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[nep]])
opaque(a != b);
// CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]);
// CHECK: [[ltp:_.*]] = Lt(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[ltp]])
opaque(a < b);
// CHECK: [[lep:_.*]] = Le([[a]], [[b]]);
// CHECK: [[lep:_.*]] = Le(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[lep]])
opaque(a <= b);
// CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]);
// CHECK: [[gtp:_.*]] = Gt(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[gtp]])
opaque(a > b);
// CHECK: [[gep:_.*]] = Ge([[a]], [[b]]);
// CHECK: [[gep:_.*]] = Ge(copy [[a]], copy [[b]]);
// CHECK: opaque::<bool>(move [[gep]])
opaque(a >= b);
}
@ -731,13 +731,13 @@ fn wide_ptr_integer() {
fn borrowed<T: Copy + Freeze>(x: T) {
// CHECK-LABEL: fn borrowed(
// CHECK: bb0: {
// CHECK-NEXT: _2 = _1;
// CHECK-NEXT: _2 = copy _1;
// CHECK-NEXT: _3 = &_1;
// CHECK-NEXT: _0 = opaque::<&T>(_3)
// CHECK-NEXT: _0 = opaque::<&T>(copy _3)
// CHECK: bb1: {
// CHECK-NEXT: _0 = opaque::<T>(_1)
// CHECK-NEXT: _0 = opaque::<T>(copy _1)
// CHECK: bb2: {
// CHECK-NEXT: _0 = opaque::<T>(_1)
// CHECK-NEXT: _0 = opaque::<T>(copy _1)
mir! {
{
let a = x;
@ -761,13 +761,13 @@ fn borrowed<T: Copy + Freeze>(x: T) {
fn non_freeze<T: Copy>(x: T) {
// CHECK-LABEL: fn non_freeze(
// CHECK: bb0: {
// CHECK-NEXT: _2 = _1;
// CHECK-NEXT: _2 = copy _1;
// CHECK-NEXT: _3 = &_1;
// CHECK-NEXT: _0 = opaque::<&T>(_3)
// CHECK-NEXT: _0 = opaque::<&T>(copy _3)
// CHECK: bb1: {
// CHECK-NEXT: _0 = opaque::<T>(_2)
// CHECK-NEXT: _0 = opaque::<T>(copy _2)
// CHECK: bb2: {
// CHECK-NEXT: _0 = opaque::<T>((*_3))
// CHECK-NEXT: _0 = opaque::<T>(copy (*_3))
mir! {
{
let a = x;
@ -789,7 +789,7 @@ fn non_freeze<T: Copy>(x: T) {
// Check that we can const-prop into `from_raw_parts`
fn slice_const_length(x: &[i32]) -> *const [i32] {
// CHECK-LABEL: fn slice_const_length(
// CHECK: _0 = *const [i32] from ({{_[0-9]+}}, const 123_usize);
// CHECK: _0 = *const [i32] from (copy {{_[0-9]+}}, const 123_usize);
let ptr = x.as_ptr();
let len = 123;
std::intrinsics::aggregate_raw_ptr(ptr, len)
@ -804,15 +804,15 @@ fn meta_of_ref_to_slice(x: *const i32) -> usize {
fn slice_from_raw_parts_as_ptr(x: *const u16, n: usize) -> (*const u16, *const f32) {
// CHECK-LABEL: fn slice_from_raw_parts_as_ptr
// CHECK: _8 = _1 as *const f32 (PtrToPtr);
// CHECK: _0 = (_1, move _8);
// CHECK: _8 = copy _1 as *const f32 (PtrToPtr);
// CHECK: _0 = (copy _1, move _8);
let ptr: *const [u16] = std::intrinsics::aggregate_raw_ptr(x, n);
(ptr as *const u16, ptr as *const f32)
}
fn casts_before_aggregate_raw_ptr(x: *const u32) -> *const [u8] {
// CHECK-LABEL: fn casts_before_aggregate_raw_ptr
// CHECK: _0 = *const [u8] from (_1, const 4_usize);
// CHECK: _0 = *const [u8] from (copy _1, const 4_usize);
let x = x as *const [u8; 4];
let x = x as *const u8;
let x = x as *const ();
@ -821,7 +821,7 @@ fn casts_before_aggregate_raw_ptr(x: *const u32) -> *const [u8] {
fn manual_slice_mut_len(x: &mut [i32]) -> usize {
// CHECK-LABEL: fn manual_slice_mut_len
// CHECK: _0 = PtrMetadata(_1);
// CHECK: _0 = PtrMetadata(copy _1);
let x: *mut [i32] = x;
let x: *const [i32] = x;
std::intrinsics::ptr_metadata(x)
@ -844,38 +844,38 @@ fn generic_cast_metadata<T, A: ?Sized, B: ?Sized>(ps: *const [T], pa: *const A,
// when the pointee metadata do or don't match, respectively.
// Metadata usize -> (), do not optimize.
// CHECK: [[T:_.+]] = _1 as
// CHECK-NEXT: PtrMetadata([[T]])
// CHECK: [[T:_.+]] = copy _1 as
// CHECK-NEXT: PtrMetadata(copy [[T]])
let t1 = CastPtrToPtr::<_, *const T>(ps);
let m1 = PtrMetadata(t1);
// `(&A, [T])` has `usize` metadata, same as `[T]`, yes optimize.
// CHECK: [[T:_.+]] = _1 as
// CHECK-NEXT: PtrMetadata(_1)
// CHECK: [[T:_.+]] = copy _1 as
// CHECK-NEXT: PtrMetadata(copy _1)
let t2 = CastPtrToPtr::<_, *const (&A, [T])>(ps);
let m2 = PtrMetadata(t2);
// Tail `A` and tail `B`, do not optimize.
// CHECK: [[T:_.+]] = _2 as
// CHECK-NEXT: PtrMetadata([[T]])
// CHECK: [[T:_.+]] = copy _2 as
// CHECK-NEXT: PtrMetadata(copy [[T]])
let t3 = CastPtrToPtr::<_, *const (T, B)>(pa);
let m3 = PtrMetadata(t3);
// Both have tail `A`, yes optimize.
// CHECK: [[T:_.+]] = _2 as
// CHECK-NEXT: PtrMetadata(_2)
// CHECK: [[T:_.+]] = copy _2 as
// CHECK-NEXT: PtrMetadata(copy _2)
let t4 = CastPtrToPtr::<_, *const (T, A)>(pa);
let m4 = PtrMetadata(t4);
// Tail `B` and tail `A`, do not optimize.
// CHECK: [[T:_.+]] = _3 as
// CHECK-NEXT: PtrMetadata([[T]])
// CHECK: [[T:_.+]] = copy _3 as
// CHECK-NEXT: PtrMetadata(copy [[T]])
let t5 = CastPtrToPtr::<_, *mut A>(pb);
let m5 = PtrMetadata(t5);
// Both have tail `B`, yes optimize.
// CHECK: [[T:_.+]] = _3 as
// CHECK-NEXT: PtrMetadata(_3)
// CHECK: [[T:_.+]] = copy _3 as
// CHECK-NEXT: PtrMetadata(copy _3)
let t6 = CastPtrToPtr::<_, *mut B>(pb);
let m6 = PtrMetadata(t6);
@ -891,21 +891,21 @@ fn cast_pointer_eq(p1: *mut u8, p2: *mut u32, p3: *mut u32, p4: *mut [u32]) {
// CHECK: debug p3 => [[P3:_3]];
// CHECK: debug p4 => [[P4:_4]];
// CHECK: [[M1:_.+]] = [[P1]] as *const u32 (PtrToPtr);
// CHECK: [[M2:_.+]] = [[P2]] as *const u32 (PtrToPtr);
// CHECK: [[M3:_.+]] = [[P3]] as *const u32 (PtrToPtr);
// CHECK: [[M4:_.+]] = [[P4]] as *const u32 (PtrToPtr);
// CHECK: [[M1:_.+]] = copy [[P1]] as *const u32 (PtrToPtr);
// CHECK: [[M2:_.+]] = copy [[P2]] as *const u32 (PtrToPtr);
// CHECK: [[M3:_.+]] = copy [[P3]] as *const u32 (PtrToPtr);
// CHECK: [[M4:_.+]] = copy [[P4]] as *const u32 (PtrToPtr);
let m1 = p1 as *const u32;
let m2 = p2 as *const u32;
let m3 = p3 as *const u32;
let m4 = p4 as *const u32;
// CHECK-NOT: Eq
// CHECK: Eq([[M1]], [[M2]])
// CHECK: Eq(copy [[M1]], copy [[M2]])
// CHECK-NOT: Eq
// CHECK: Eq([[P2]], [[P3]])
// CHECK: Eq(copy [[P2]], copy [[P3]])
// CHECK-NOT: Eq
// CHECK: Eq([[M3]], [[M4]])
// CHECK: Eq(copy [[M3]], copy [[M4]])
// CHECK-NOT: Eq
let eq_different_thing = m1 == m2;
let eq_optimize = m2 == m3;
@ -918,11 +918,11 @@ fn cast_pointer_eq(p1: *mut u8, p2: *mut u32, p3: *mut u32, p4: *mut [u32]) {
unsafe fn cast_pointer_then_transmute(thin: *mut u32, fat: *mut [u8]) {
// CHECK-LABEL: fn cast_pointer_then_transmute
// CHECK: [[UNUSED:_.+]] = _1 as *const () (PtrToPtr);
// CHECK: = _1 as usize (Transmute);
// CHECK: [[UNUSED:_.+]] = copy _1 as *const () (PtrToPtr);
// CHECK: = copy _1 as usize (Transmute);
let thin_addr: usize = std::intrinsics::transmute(thin as *const ());
// CHECK: [[TEMP2:_.+]] = _2 as *const () (PtrToPtr);
// CHECK: [[TEMP2:_.+]] = copy _2 as *const () (PtrToPtr);
// CHECK: = move [[TEMP2]] as usize (Transmute);
let fat_addr: usize = std::intrinsics::transmute(fat as *const ());
}
@ -935,11 +935,11 @@ fn remove_casts_must_change_both_sides(mut_a: &*mut u8, mut_b: *mut u8) -> bool
// to be locals, so make sure we don't change one without the other, as
// that would be a type error.
{
// CHECK: [[A:_.+]] = (*_1) as *const u8 (PtrToPtr);
// CHECK: [[A:_.+]] = copy (*_1) as *const u8 (PtrToPtr);
let a = *mut_a as *const u8;
// CHECK: [[B:_.+]] = _2 as *const u8 (PtrToPtr);
// CHECK: [[B:_.+]] = copy _2 as *const u8 (PtrToPtr);
let b = mut_b as *const u8;
// CHECK: _0 = Eq([[A]], [[B]]);
// CHECK: _0 = Eq(copy [[A]], copy [[B]]);
RET = a == b;
Return()
}

View File

@ -18,9 +18,9 @@ fn fn0() {
// CHECK-NEXT: _1 = const 1_usize;
// CHECK-NEXT: _2 = [const 42_u128; 6];
// CHECK-NEXT: _2[1 of 2] = const 1_u128;
// CHECK-NEXT: _3 = (_2,);
// CHECK-NEXT: _4 = _3;
// CHECK-NEXT: _5 = fn1((_3.0: [u128; 6]), _3)
// CHECK-NEXT: _3 = (copy _2,);
// CHECK-NEXT: _4 = copy _3;
// CHECK-NEXT: _5 = fn1(copy (_3.0: [u128; 6]), copy _3)
a = 1_usize;
b = [42; 6];
b[a] = 1;

View File

@ -19,7 +19,7 @@ pub fn redundant<'a, 'b: 'a>(x: *const &'a u8) -> *const &'a u8 {
// EMIT_MIR casts.roundtrip.InstSimplify-after-simplifycfg.diff
pub fn roundtrip(x: *const u8) -> *const u8 {
// CHECK-LABEL: fn roundtrip(
// CHECK: _4 = _1;
// CHECK: _4 = copy _1;
// CHECK: _3 = move _4 as *mut u8 (PtrToPtr);
// CHECK: _2 = move _3 as *const u8 (PtrToPtr);
x as *mut u8 as *const u8
@ -28,7 +28,7 @@ pub fn roundtrip(x: *const u8) -> *const u8 {
// EMIT_MIR casts.roundtrip.InstSimplify-after-simplifycfg.diff
pub fn cast_thin_via_aggregate(x: *const u8) -> *const () {
// CHECK-LABEL: fn cast_thin_via_aggregate(
// CHECK: _2 = _1;
// CHECK: _2 = copy _1;
// CHECK: _0 = move _2 as *const () (PtrToPtr);
std::intrinsics::aggregate_raw_ptr(x, ())
}

View File

@ -8,11 +8,11 @@
// EMIT_MIR ref_of_deref.references.InstSimplify-after-simplifycfg.diff
// CHECK-LABEL: references
pub fn references(const_ref: &i32, mut_ref: &mut [i32]) {
// CHECK: _3 = _1;
// CHECK: _3 = copy _1;
let _a = &*const_ref;
// CHECK: _4 = &(*_2);
let _b = &*mut_ref;
// CHECK: _5 = _2;
// CHECK: _5 = copy _2;
let _c = &mut *mut_ref;
// CHECK: _6 = &raw const (*_1);
let _d = &raw const *const_ref;
@ -31,10 +31,10 @@ pub unsafe fn pointers(const_ptr: *const [i32], mut_ptr: *mut i32) {
let _b = &*mut_ptr;
// CHECK: _5 = &mut (*_2);
let _c = &mut *mut_ptr;
// CHECK: _6 = _1;
// CHECK: _6 = copy _1;
let _d = &raw const *const_ptr;
// CHECK: _7 = &raw const (*_2);
let _e = &raw const *mut_ptr;
// CHECK: _8 = _2;
// CHECK: _8 = copy _2;
let _f = &raw mut *mut_ptr;
}

View File

@ -6,7 +6,7 @@ pub fn unwrap_unchecked(x: Option<i32>) -> i32 {
// CHECK-LABEL: fn unwrap_unchecked(
// CHECK-NOT: UbChecks()
// CHECK: [[assume:_.*]] = const false;
// CHECK-NEXT: assume([[assume]]);
// CHECK-NEXT: assume(copy [[assume]]);
// CHECK-NEXT: unreachable_unchecked::precondition_check
unsafe { x.unwrap_unchecked() }
}

View File

@ -24,11 +24,11 @@ fn too_complex(x: Result<i32, usize>) -> Option<i32> {
// CHECK: bb4: {
// CHECK: goto -> bb6;
// CHECK: bb5: {
// CHECK: {{_.*}} = (([[controlflow]] as Break).0: usize);
// CHECK: {{_.*}} = copy (([[controlflow]] as Break).0: usize);
// CHECK: _0 = Option::<i32>::None;
// CHECK: goto -> bb7;
// CHECK: bb6: {
// CHECK: {{_.*}} = (([[controlflow]] as Continue).0: i32);
// CHECK: {{_.*}} = copy (([[controlflow]] as Continue).0: i32);
// CHECK: _0 = Option::<i32>::Some(
// CHECK: goto -> bb7;
// CHECK: bb7: {
@ -49,16 +49,16 @@ fn too_complex(x: Result<i32, usize>) -> Option<i32> {
fn identity(x: Result<i32, i32>) -> Result<i32, i32> {
// CHECK-LABEL: fn identity(
// CHECK: bb0: {
// CHECK: [[x:_.*]] = _1;
// CHECK: [[x:_.*]] = copy _1;
// CHECK: switchInt(move {{_.*}}) -> [0: bb7, 1: bb6, otherwise: bb1];
// CHECK: bb1: {
// CHECK: unreachable;
// CHECK: bb2: {
// CHECK: {{_.*}} = (([[controlflow:_.*]] as Continue).0: i32);
// CHECK: {{_.*}} = copy (([[controlflow:_.*]] as Continue).0: i32);
// CHECK: _0 = Result::<i32, i32>::Ok(
// CHECK: goto -> bb4;
// CHECK: bb3: {
// CHECK: {{_.*}} = (([[controlflow]] as Break).0: std::result::Result<std::convert::Infallible, i32>);
// CHECK: {{_.*}} = copy (([[controlflow]] as Break).0: std::result::Result<std::convert::Infallible, i32>);
// CHECK: _0 = Result::<i32, i32>::Err(
// CHECK: goto -> bb4;
// CHECK: bb4: {
@ -160,13 +160,13 @@ fn multiple_match(x: u8) -> u8 {
mir! {
{
// CHECK: bb0: {
// CHECK: switchInt([[x:_.*]]) -> [3: bb1, otherwise: bb2];
// CHECK: switchInt(copy [[x:_.*]]) -> [3: bb1, otherwise: bb2];
match x { 3 => bb1, _ => bb2 }
}
bb1 = {
// We know `x == 3`, so we can take `bb3`.
// CHECK: bb1: {
// CHECK: {{_.*}} = [[x]];
// CHECK: {{_.*}} = copy [[x]];
// CHECK: goto -> bb3;
let y = x;
match y { 3 => bb3, _ => bb4 }
@ -174,7 +174,7 @@ fn multiple_match(x: u8) -> u8 {
bb2 = {
// We know `x != 3`, so we can take `bb6`.
// CHECK: bb2: {
// CHECK: [[z:_.*]] = [[x]];
// CHECK: [[z:_.*]] = copy [[x]];
// CHECK: goto -> bb6;
let z = x;
match z { 3 => bb5, _ => bb6 }
@ -203,7 +203,7 @@ fn multiple_match(x: u8) -> u8 {
bb6 = {
// We know `z != 3`, so we CANNOT take `bb7`.
// CHECK: bb6: {
// CHECK: switchInt([[z]]) -> [1: bb7, otherwise: bb8];
// CHECK: switchInt(copy [[z]]) -> [1: bb7, otherwise: bb8];
match z { 1 => bb7, _ => bb8 }
}
bb7 = {
@ -467,12 +467,12 @@ fn assume(a: u8, b: bool) -> u8 {
mir! {
{
// CHECK: bb0: {
// CHECK-NEXT: switchInt(_1) -> [7: bb1, otherwise: bb2]
// CHECK-NEXT: switchInt(copy _1) -> [7: bb1, otherwise: bb2]
match a { 7 => bb1, _ => bb2 }
}
bb1 = {
// CHECK: bb1: {
// CHECK-NEXT: assume(_2);
// CHECK-NEXT: assume(copy _2);
// CHECK-NEXT: goto -> bb6;
Assume(b);
Goto(bb3)
@ -484,7 +484,7 @@ fn assume(a: u8, b: bool) -> u8 {
}
bb3 = {
// CHECK: bb3: {
// CHECK-NEXT: switchInt(_2) -> [0: bb4, otherwise: bb5];
// CHECK-NEXT: switchInt(copy _2) -> [0: bb4, otherwise: bb5];
match b { false => bb4, _ => bb5 }
}
bb4 = {

View File

@ -6,7 +6,7 @@
pub fn array_bound<const N: usize>(index: usize, slice: &[u8; N]) -> u8 {
// CHECK-LABEL: fn array_bound(
// CHECK-NOT: Lt
// CHECK: Lt(_1, const N);
// CHECK: Lt(copy _1, const N);
// CHECK-NOT: Lt
if index < slice.len() { slice[index] } else { 42 }
}
@ -15,7 +15,7 @@
pub fn array_bound_mut<const N: usize>(index: usize, slice: &mut [u8; N]) -> u8 {
// CHECK-LABEL: fn array_bound_mut(
// CHECK-NOT: Lt
// CHECK: Lt(_1, const N);
// CHECK: Lt(copy _1, const N);
// CHECK-NOT: Lt
// CHECK: Lt(const 0_usize, const N)
// CHECK-NOT: Lt

View File

@ -197,7 +197,7 @@ pub fn with_overflow(a: i32, b: i32) {
pub fn read_via_copy_primitive(r: &i32) -> i32 {
// CHECK-LABEL: fn read_via_copy_primitive(
// CHECK: [[tmp:_.*]] = &raw const (*_1);
// CHECK: _0 = (*[[tmp]]);
// CHECK: _0 = copy (*[[tmp]]);
// CHECK: return;
unsafe { core::intrinsics::read_via_copy(r) }
@ -207,7 +207,7 @@ pub fn read_via_copy_primitive(r: &i32) -> i32 {
pub fn read_via_copy_uninhabited(r: &Never) -> Never {
// CHECK-LABEL: fn read_via_copy_uninhabited(
// CHECK: [[tmp:_.*]] = &raw const (*_1);
// CHECK: _0 = (*[[tmp]]);
// CHECK: _0 = copy (*[[tmp]]);
// CHECK: unreachable;
unsafe { core::intrinsics::read_via_copy(r) }

View File

@ -10,17 +10,17 @@
pub fn slice_index_usize(slice: &[u32], index: usize) -> u32 {
// CHECK-LABEL: slice_index_usize
// CHECK: [[LEN:_[0-9]+]] = Len((*_1))
// CHECK: Lt(_2, [[LEN]])
// CHECK: Lt(copy _2, copy [[LEN]])
// CHECK-NOT: precondition_check
// CHECK: _0 = (*_1)[_2];
// CHECK: _0 = copy (*_1)[_2];
slice[index]
}
// EMIT_MIR slice_index.slice_get_mut_usize.PreCodegen.after.mir
pub fn slice_get_mut_usize(slice: &mut [u32], index: usize) -> Option<&mut u32> {
// CHECK-LABEL: slice_get_mut_usize
// CHECK: [[LEN:_[0-9]+]] = PtrMetadata(_1)
// CHECK: Lt(_2, move [[LEN]])
// CHECK: [[LEN:_[0-9]+]] = PtrMetadata(copy _1)
// CHECK: Lt(copy _2, move [[LEN]])
// CHECK-NOT: precondition_check
slice.get_mut(index)
}
@ -37,9 +37,9 @@ pub unsafe fn slice_get_unchecked_mut_range(slice: &mut [u32], index: Range<usiz
// CHECK: [[START:_[0-9]+]] = move (_2.0: usize);
// CHECK: [[END:_[0-9]+]] = move (_2.1: usize);
// CHECK: precondition_check
// CHECK: [[LEN:_[0-9]+]] = SubUnchecked([[END]], [[START]]);
// CHECK: [[PTR:_[0-9]+]] = Offset({{_[0-9]+}}, [[START]]);
// CHECK: [[SLICE:_[0-9]+]] = *mut [u32] from ([[PTR]], [[LEN]])
// CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy [[END]], copy [[START]]);
// CHECK: [[PTR:_[0-9]+]] = Offset(copy {{_[0-9]+}}, copy [[START]]);
// CHECK: [[SLICE:_[0-9]+]] = *mut [u32] from (copy [[PTR]], copy [[LEN]])
// CHECK: _0 = &mut (*[[SLICE]]);
slice.get_unchecked_mut(index)
}
@ -53,8 +53,8 @@ pub unsafe fn slice_ptr_get_unchecked_range(
// CHECK: [[START:_[0-9]+]] = move (_2.0: usize);
// CHECK: [[END:_[0-9]+]] = move (_2.1: usize);
// CHECK: precondition_check
// CHECK: [[LEN:_[0-9]+]] = SubUnchecked([[END]], [[START]]);
// CHECK: [[PTR:_[0-9]+]] = Offset({{_[0-9]+}}, [[START]]);
// CHECK: _0 = *const [u32] from ([[PTR]], [[LEN]])
// CHECK: [[LEN:_[0-9]+]] = SubUnchecked(copy [[END]], copy [[START]]);
// CHECK: [[PTR:_[0-9]+]] = Offset(copy {{_[0-9]+}}, copy [[START]]);
// CHECK: _0 = *const [u32] from (copy [[PTR]], copy [[LEN]])
slice.get_unchecked(index)
}

View File

@ -16,7 +16,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: bb0: {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &a; // This borrow is only used once.
@ -32,7 +32,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[btmp:_.*]] = &[[a2]];
// CHECK: [[b]] = move [[btmp]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let a2 = 7_usize;
@ -49,7 +49,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &a;
@ -64,7 +64,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[d:_.*]] = &raw mut [[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let mut b = &a;
@ -78,7 +78,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: bb4: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 7_usize;
let b = &a;
@ -91,10 +91,10 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: bb5: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b1:_.*]] = &[[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[b2:_.*]] = [[b1]];
// CHECK: [[c2:_.*]] = [[a]];
// CHECK: [[b3:_.*]] = [[b2]];
// CHECK: [[c:_.*]] = copy [[a]];
// CHECK: [[b2:_.*]] = copy [[b1]];
// CHECK: [[c2:_.*]] = copy [[a]];
// CHECK: [[b3:_.*]] = copy [[b2]];
let a = 7_usize;
let b1 = &a;
@ -111,7 +111,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
{
// CHECK: bb6: {
// CHECK-NOT: {{_.*}} = &(*_1);
// CHECK: [[b:_.*]] = (*_1);
// CHECK: [[b:_.*]] = copy (*_1);
let a = &*single;
let b = *a; // This should be optimized as `*single`.
@ -124,7 +124,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[a:_.*]] = &(*_2);
// CHECK: [[tmp:_.*]] = &(*_1);
// CHECK: _2 = move [[tmp]];
// CHECK: [[b:_.*]] = (*[[a]]);
// CHECK: [[b:_.*]] = copy (*[[a]]);
let a = &*multiple;
multiple = &*single;
@ -138,7 +138,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &a;
@ -154,7 +154,7 @@ fn reference_propagation<'a, T: Copy>(single: &'a T, mut multiple: &'a T) {
// CHECK: [[b:_.*]] = &[[a]];
// CHECK: [[d:_.*]] = &mut [[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let mut b = &a;
@ -172,7 +172,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: bb0: {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let mut a = 5_usize;
let b = &mut a; // This borrow is only used once.
@ -188,7 +188,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[btmp:_.*]] = &mut [[a2]];
// CHECK: [[b]] = move [[btmp]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut a2 = 7_usize;
@ -205,7 +205,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let b = &mut a;
@ -220,7 +220,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[d:_.*]] = &raw mut [[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut b = &mut a;
@ -234,7 +234,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: bb4: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 7_usize;
let b = &mut a;
@ -247,9 +247,9 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: bb5: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b1:_.*]] = &mut [[a]];
// CHECK: [[c:_.*]] = (*[[b1]]);
// CHECK: [[c:_.*]] = copy (*[[b1]]);
// CHECK: [[b2:_.*]] = move [[b1]];
// CHECK: [[c2:_.*]] = (*[[b2]]);
// CHECK: [[c2:_.*]] = copy (*[[b2]]);
// CHECK: [[b3:_.*]] = move [[b2]];
let mut a = 7_usize;
@ -267,7 +267,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
{
// CHECK: bb6: {
// CHECK-NOT: {{_.*}} = &(*_1);
// CHECK: [[b:_.*]] = (*_1);
// CHECK: [[b:_.*]] = copy (*_1);
let a = &mut *single;
let b = *a; // This should be optimized as `*single`.
@ -280,7 +280,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[a:_.*]] = &mut (*_2);
// CHECK: [[tmp:_.*]] = &mut (*_1);
// CHECK: _2 = move [[tmp]];
// CHECK: [[b:_.*]] = (*[[a]]);
// CHECK: [[b:_.*]] = copy (*[[a]]);
let a = &mut *multiple;
multiple = &mut *single;
@ -295,7 +295,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let b = &mut a;
@ -311,7 +311,7 @@ fn reference_propagation_mut<'a, T: Copy>(single: &'a mut T, mut multiple: &'a m
// CHECK: [[b:_.*]] = &mut [[a]];
// CHECK: [[d:_.*]] = &mut [[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut b = &mut a;
@ -329,7 +329,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: bb0: {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &raw const a; // This borrow is only used once.
@ -345,7 +345,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[btmp:_.*]] = &raw const [[a2]];
// CHECK: [[b]] = move [[btmp]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let a2 = 7_usize;
@ -362,7 +362,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &raw const a;
@ -377,7 +377,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[d:_.*]] = &raw mut [[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let mut b = &raw const a;
@ -391,7 +391,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: bb4: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 7_usize;
let b = &raw const a;
@ -404,10 +404,10 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: bb5: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b1:_.*]] = &raw const [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[b2:_.*]] = [[b1]];
// CHECK: [[c2:_.*]] = [[a]];
// CHECK: [[b3:_.*]] = [[b2]];
// CHECK: [[c:_.*]] = copy [[a]];
// CHECK: [[b2:_.*]] = copy [[b1]];
// CHECK: [[c2:_.*]] = copy [[a]];
// CHECK: [[b3:_.*]] = copy [[b2]];
let a = 7_usize;
let b1 = &raw const a;
@ -424,7 +424,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
unsafe {
// CHECK: bb6: {
// CHECK-NOT: {{_.*}} = &(*_1);
// CHECK: [[b:_.*]] = (*_1);
// CHECK: [[b:_.*]] = copy (*_1);
let a = &raw const *single;
let b = *a; // This should be optimized as `*single`.
@ -437,7 +437,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[a:_.*]] = &raw const (*_2);
// CHECK: [[tmp:_.*]] = &raw const (*_1);
// CHECK: _2 = move [[tmp]];
// CHECK: [[b:_.*]] = (*[[a]]);
// CHECK: [[b:_.*]] = copy (*[[a]]);
let a = &raw const *multiple;
multiple = &raw const *single;
@ -451,7 +451,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[a:_.*]] = const 13_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[d:_.*]] = &raw const [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 13_usize;
let b = &raw const a;
@ -466,7 +466,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let a = 5_usize;
let b = &raw const a;
@ -482,7 +482,7 @@ fn reference_propagation_const_ptr<T: Copy>(single: *const T, mut multiple: *con
// CHECK: [[b:_.*]] = &raw const [[a]];
// CHECK: [[d:_.*]] = &mut [[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let a = 5_usize;
let mut b = &raw const a;
@ -500,7 +500,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: bb0: {
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[c:_.*]] = [[a]];
// CHECK: [[c:_.*]] = copy [[a]];
let mut a = 5_usize;
let b = &raw mut a; // This borrow is only used once.
@ -516,7 +516,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[btmp:_.*]] = &raw mut [[a2]];
// CHECK: [[b]] = move [[btmp]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut a2 = 7_usize;
@ -533,7 +533,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let b = &raw mut a;
@ -548,7 +548,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[a:_.*]] = const 5_usize;
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[d:_.*]] = &raw mut [[b]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut b = &raw mut a;
@ -562,7 +562,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: bb4: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 7_usize;
let b = &raw mut a;
@ -575,10 +575,10 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: bb5: {
// CHECK: [[a:_.*]] = const 7_usize;
// CHECK: [[b1:_.*]] = &raw mut [[a]];
// CHECK: [[c:_.*]] = (*[[b1]]);
// CHECK: [[b2:_.*]] = [[b1]];
// CHECK: [[c2:_.*]] = (*[[b2]]);
// CHECK: [[b3:_.*]] = [[b2]];
// CHECK: [[c:_.*]] = copy (*[[b1]]);
// CHECK: [[b2:_.*]] = copy [[b1]];
// CHECK: [[c2:_.*]] = copy (*[[b2]]);
// CHECK: [[b3:_.*]] = copy [[b2]];
let mut a = 7_usize;
let b1 = &raw mut a;
@ -595,7 +595,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
unsafe {
// CHECK: bb6: {
// CHECK-NOT: {{_.*}} = &(*_1);
// CHECK: [[b:_.*]] = (*_1);
// CHECK: [[b:_.*]] = copy (*_1);
let a = &raw mut *single;
let b = *a; // This should be optimized as `*single`.
@ -608,7 +608,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[a:_.*]] = &raw mut (*_2);
// CHECK: [[tmp:_.*]] = &raw mut (*_1);
// CHECK: _2 = move [[tmp]];
// CHECK: [[b:_.*]] = (*[[a]]);
// CHECK: [[b:_.*]] = copy (*[[a]]);
let a = &raw mut *multiple;
multiple = &raw mut *single;
@ -623,7 +623,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[d:_.*]] = &[[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let b = &raw mut a;
@ -639,7 +639,7 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
// CHECK: [[b:_.*]] = &raw mut [[a]];
// CHECK: [[d:_.*]] = &mut [[b]];
// FIXME this could be [[a]]
// CHECK: [[c:_.*]] = (*[[b]]);
// CHECK: [[c:_.*]] = copy (*[[b]]);
let mut a = 5_usize;
let mut b = &raw mut a;
@ -653,8 +653,8 @@ fn reference_propagation_mut_ptr<T: Copy>(single: *mut T, mut multiple: *mut T)
fn read_through_raw(x: &mut usize) -> usize {
// CHECK-LABEL: read_through_raw
// CHECK: bb0: {
// CHECK-NEXT: _0 = (*_1);
// CHECK-NEXT: _0 = (*_1);
// CHECK-NEXT: _0 = copy (*_1);
// CHECK-NEXT: _0 = copy (*_1);
// CHECK-NEXT: return;
use std::intrinsics::mir::*;
@ -680,7 +680,7 @@ fn read_through_raw(x: &mut usize) -> usize {
#[custom_mir(dialect = "runtime", phase = "post-cleanup")]
fn multiple_storage() {
// CHECK-LABEL: multiple_storage
// CHECK: _3 = (*_2);
// CHECK: _3 = copy (*_2);
use std::intrinsics::mir::*;
mir! {
@ -706,7 +706,7 @@ fn multiple_storage() {
#[custom_mir(dialect = "runtime", phase = "post-cleanup")]
fn dominate_storage() {
// CHECK-LABEL: dominate_storage
// CHECK: _5 = (*_2);
// CHECK: _5 = copy (*_2);
use std::intrinsics::mir::*;
mir! {
@ -798,12 +798,12 @@ fn unique_with_copies() {
// CHECK: [[a:_.*]] = const 0_i32;
// CHECK: [[x:_.*]] = &raw mut [[a]];
// CHECK-NOT: [[a]]
// CHECK: [[tmp:_.*]] = (*[[x]]);
// CHECK: [[tmp:_.*]] = copy (*[[x]]);
// CHECK-NEXT: opaque::<i32>(move [[tmp]])
// CHECK-NOT: [[a]]
// CHECK: StorageDead([[a]]);
// CHECK-NOT: [[a]]
// CHECK: [[tmp:_.*]] = (*[[x]]);
// CHECK: [[tmp:_.*]] = copy (*[[x]]);
// CHECK-NEXT: opaque::<i32>(move [[tmp]])
let y = {

View File

@ -10,7 +10,7 @@
pub unsafe fn assert_nonzero_nonmax(x: u8) -> u8 {
// CHECK-LABEL: fn assert_nonzero_nonmax(
// CHECK: bb0: {
// CHECK-NEXT: switchInt({{.*}}) -> [0: [[unreachable:bb.*]], 1: [[retblock2:bb.*]], 255: [[unreachable:bb.*]], otherwise: [[retblock:bb.*]]];
// CHECK-NEXT: switchInt(copy {{_[0-9]+}}) -> [0: [[unreachable:bb.*]], 1: [[retblock2:bb.*]], 255: [[unreachable:bb.*]], otherwise: [[retblock:bb.*]]];
// CHECK-NEXT: }
// CHECK-NOT: _0 = const 1_u8;
// CHECK: [[retblock2]]: {
@ -21,7 +21,7 @@ pub unsafe fn assert_nonzero_nonmax(x: u8) -> u8 {
// CHECK-NEXT: unreachable;
// CHECK-NEXT: }
// CHECK: [[retblock]]: {
// CHECK-NEXT: _0 = _1;
// CHECK-NEXT: _0 = copy _1;
// CHECK-NEXT: return;
// CHECK-NEXT: }
mir! {

View File

@ -31,8 +31,8 @@ pub fn enums(a: usize) -> usize {
// CHECK: bb0: {
// CHECK: [[enum]] = Option::<usize>::Some
// CHECK: _5 = (([[enum]] as Some).0: usize)
// CHECK: _0 = _5
// CHECK: _5 = copy (([[enum]] as Some).0: usize)
// CHECK: _0 = copy _5
if let Some(a) = Some(a) { a } else { 0 }
}
@ -51,13 +51,13 @@ struct U {
// CHECK: bb0: {
// CHECK-NOT: [[struct]]
// CHECK: [[a_tmp]] = _1;
// CHECK: [[a_tmp]] = copy _1;
// CHECK-NOT: [[struct]]
// CHECK: [[foo]] = const 0_usize;
// CHECK-NOT: [[struct]]
// CHECK: [[a_ret]] = move [[a_tmp]];
// CHECK-NOT: [[struct]]
// CHECK: _0 = [[a_ret]];
// CHECK: _0 = copy [[a_ret]];
// CHECK-NOT: [[struct]]
U { _foo: 0, a }.a
}
@ -73,7 +73,7 @@ union Repr {
// CHECK: bb0: {
// CHECK: [[union]] = Repr {
// CHECK: _0 = ([[union]].1: u32)
// CHECK: _0 = copy ([[union]].1: u32)
unsafe { Repr { f: a }.u }
}
@ -156,10 +156,10 @@ fn copies(x: Foo) {
// CHECK: [[opt_isize:_[0-9]+]]: std::option::Option<isize>;
// CHECK: bb0: {
// CHECK: [[byte]] = ([[external]].0
// CHECK: [[unit]] = ([[external]].1
// CHECK: [[str]] = ([[external]].2
// CHECK: [[opt_isize]] = ([[external]].3
// CHECK: [[byte]] = copy ([[external]].0
// CHECK: [[unit]] = copy ([[external]].1
// CHECK: [[str]] = copy ([[external]].2
// CHECK: [[opt_isize]] = copy ([[external]].3
let y = x;
let t = y.a;
@ -181,10 +181,10 @@ fn ref_copies(x: &Foo) {
// CHECK: [[opt_isize:_[0-9]+]]: std::option::Option<isize>;
// CHECK: bb0: {
// CHECK: [[byte]] = ((*[[external]]).0
// CHECK: [[unit]] = ((*[[external]]).1
// CHECK: [[str]] = ((*[[external]]).2
// CHECK: [[opt_isize]] = ((*[[external]]).3
// CHECK: [[byte]] = copy ((*[[external]]).0
// CHECK: [[unit]] = copy ((*[[external]]).1
// CHECK: [[str]] = copy ((*[[external]]).2
// CHECK: [[opt_isize]] = copy ((*[[external]]).3
let y = *x;
let t = y.a;