2023-10-16 12:36:39 -05:00
|
|
|
// skip-filecheck
|
2023-07-20 12:03:44 -05:00
|
|
|
// Check that CopyProp does propagate return values of call terminators.
|
2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: CopyProp
|
2024-02-22 06:10:29 -06:00
|
|
|
//@ needs-unwind
|
2023-07-20 12:03:44 -05:00
|
|
|
|
|
|
|
#![feature(custom_mir, core_intrinsics)]
|
|
|
|
use std::intrinsics::mir::*;
|
|
|
|
|
|
|
|
#[inline(never)]
|
|
|
|
fn dummy(x: u8) -> u8 {
|
|
|
|
x
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR calls.nrvo.CopyProp.diff
|
|
|
|
fn nrvo() -> u8 {
|
|
|
|
let y = dummy(5); // this should get NRVO
|
|
|
|
y
|
|
|
|
}
|
|
|
|
|
|
|
|
// EMIT_MIR calls.multiple_edges.CopyProp.diff
|
|
|
|
#[custom_mir(dialect = "runtime", phase = "initial")]
|
|
|
|
fn multiple_edges(t: bool) -> u8 {
|
|
|
|
mir! {
|
|
|
|
let x: u8;
|
|
|
|
{
|
|
|
|
match t { true => bbt, _ => ret }
|
|
|
|
}
|
|
|
|
bbt = {
|
2023-12-26 12:31:52 -06:00
|
|
|
Call(x = dummy(13), ReturnTo(ret), UnwindContinue())
|
2023-07-20 12:03:44 -05:00
|
|
|
}
|
|
|
|
ret = {
|
|
|
|
// `x` is not assigned on the `bb0 -> ret` edge,
|
|
|
|
// so should not be marked as SSA for merging with `_0`.
|
|
|
|
RET = x;
|
|
|
|
Return()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Make sure the function actually gets instantiated.
|
|
|
|
nrvo();
|
|
|
|
multiple_edges(false);
|
|
|
|
}
|