rust/tests/mir-opt/copy-prop/custom_move_arg.rs
Tomasz Miąsko 78da577650 Custom MIR: Support cleanup blocks
Cleanup blocks are declared with `bb (cleanup) = { ... }`.

`Call` and `Drop` terminators take an additional argument describing the
unwind action, which is one of the following:

* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`

Also support unwind resume and unwind terminate terminators:

* `UnwindResume()`
* `UnwindTerminate(reason)`
2023-11-14 08:23:58 +01:00

35 lines
679 B
Rust

// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
// unit-test: CopyProp
#![feature(custom_mir, core_intrinsics)]
#![allow(unused_assignments)]
extern crate core;
use core::intrinsics::mir::*;
struct NotCopy(bool);
// EMIT_MIR custom_move_arg.f.CopyProp.diff
#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
fn f(_1: NotCopy) {
mir!({
let _2 = _1;
Call(RET = opaque(Move(_1)), bb1, UnwindContinue())
}
bb1 = {
let _3 = Move(_2);
Call(RET = opaque(_3), bb2, UnwindContinue())
}
bb2 = {
Return()
})
}
#[inline(never)]
fn opaque<T>(_t: T) {}
fn main() {
f(NotCopy(true));
println!("hi");
}