Add Drop terminator to SMIR
This commit is contained in:
parent
9b99ff76b2
commit
7dd59fceef
3 changed files with 18 additions and 3 deletions
|
@ -162,7 +162,11 @@ fn rustc_terminator_to_terminator(
|
||||||
Terminate => Terminator::Abort,
|
Terminate => Terminator::Abort,
|
||||||
Return => Terminator::Return,
|
Return => Terminator::Return,
|
||||||
Unreachable => Terminator::Unreachable,
|
Unreachable => Terminator::Unreachable,
|
||||||
Drop { .. } => todo!(),
|
Drop { place, target, unwind } => Terminator::Drop {
|
||||||
|
place: rustc_place_to_place(place),
|
||||||
|
target: target.as_usize(),
|
||||||
|
unwind: rustc_unwind_to_unwind(unwind),
|
||||||
|
},
|
||||||
Call { func, args, destination, target, unwind, from_hir_call: _, fn_span: _ } => {
|
Call { func, args, destination, target, unwind, from_hir_call: _, fn_span: _ } => {
|
||||||
Terminator::Call {
|
Terminator::Call {
|
||||||
func: rustc_op_to_op(func),
|
func: rustc_op_to_op(func),
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub enum Terminator {
|
||||||
Drop {
|
Drop {
|
||||||
place: Place,
|
place: Place,
|
||||||
target: usize,
|
target: usize,
|
||||||
unwind: Option<usize>,
|
unwind: UnwindAction,
|
||||||
},
|
},
|
||||||
Call {
|
Call {
|
||||||
func: Operand,
|
func: Operand,
|
||||||
|
|
|
@ -60,6 +60,15 @@ fn test_stable_mir(tcx: TyCtxt<'_>) {
|
||||||
stable_mir::mir::Terminator::Call { .. } => {}
|
stable_mir::mir::Terminator::Call { .. } => {}
|
||||||
other => panic!("{other:?}"),
|
other => panic!("{other:?}"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap();
|
||||||
|
let body = drop.body();
|
||||||
|
assert_eq!(body.blocks.len(), 2);
|
||||||
|
let block = &body.blocks[0];
|
||||||
|
match &block.terminator {
|
||||||
|
stable_mir::mir::Terminator::Drop { .. } => {}
|
||||||
|
other => panic!("{other:?}"),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use internal API to find a function in a crate.
|
// Use internal API to find a function in a crate.
|
||||||
|
@ -131,7 +140,9 @@ fn generate_input(path: &str) -> std::io::Result<()> {
|
||||||
let x_64 = foo::bar(x);
|
let x_64 = foo::bar(x);
|
||||||
let y_64 = foo::bar(y);
|
let y_64 = foo::bar(y);
|
||||||
x_64.wrapping_add(y_64)
|
x_64.wrapping_add(y_64)
|
||||||
}}"#
|
}}
|
||||||
|
|
||||||
|
pub fn drop(_: String) {{}}"#
|
||||||
)?;
|
)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue