Lower the assume intrinsic to a MIR statement
This commit is contained in:
parent
3c72788461
commit
3f07645120
33 changed files with 212 additions and 30 deletions
|
@ -105,6 +105,9 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
// safe (at least as emitted during MIR construction)
|
||||
}
|
||||
|
||||
// Move to above list once mir construction uses it.
|
||||
StatementKind::Assume(..) => unreachable!(),
|
||||
|
||||
StatementKind::CopyNonOverlapping(..) => unreachable!(),
|
||||
}
|
||||
self.super_statement(statement, location);
|
||||
|
|
|
@ -826,6 +826,7 @@ pub(super) fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span>
|
|||
// Retain spans from all other statements
|
||||
StatementKind::FakeRead(box (_, _)) // Not including `ForGuardBinding`
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assume(..)
|
||||
| StatementKind::Assign(_)
|
||||
| StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::Deinit(..)
|
||||
|
|
|
@ -53,6 +53,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
|
|||
| StatementKind::StorageDead(_)
|
||||
| StatementKind::Coverage(_)
|
||||
| StatementKind::CopyNonOverlapping(_)
|
||||
| StatementKind::Assume(_)
|
||||
| StatementKind::Nop => (),
|
||||
|
||||
StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => {
|
||||
|
|
|
@ -538,6 +538,7 @@ impl<'a> Conflicts<'a> {
|
|||
| StatementKind::AscribeUserType(..)
|
||||
| StatementKind::Coverage(..)
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assume(..)
|
||||
| StatementKind::Nop => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1453,6 +1453,7 @@ impl<'tcx> Visitor<'tcx> for EnsureGeneratorFieldAssignmentsNeverAlias<'_> {
|
|||
| StatementKind::AscribeUserType(..)
|
||||
| StatementKind::Coverage(..)
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assume(..)
|
||||
| StatementKind::Nop => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,17 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
|||
drop(args);
|
||||
terminator.kind = TerminatorKind::Goto { target };
|
||||
}
|
||||
sym::assume => {
|
||||
let target = target.unwrap();
|
||||
let mut args = args.drain(..);
|
||||
block.statements.push(Statement {
|
||||
source_info: terminator.source_info,
|
||||
kind: StatementKind::Assume(Box::new(args.next().unwrap())),
|
||||
});
|
||||
assert_eq!(args.next(), None, "Extra argument for assume intrinsic");
|
||||
drop(args);
|
||||
terminator.kind = TerminatorKind::Goto { target };
|
||||
}
|
||||
sym::wrapping_add | sym::wrapping_sub | sym::wrapping_mul => {
|
||||
if let Some(target) = *target {
|
||||
let lhs;
|
||||
|
|
|
@ -52,6 +52,7 @@ impl RemoveNoopLandingPads {
|
|||
| StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::Deinit(..)
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assume(..)
|
||||
| StatementKind::Retag { .. } => {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ fn is_likely_const<'tcx>(mut tracked_place: Place<'tcx>, block: &BasicBlockData<
|
|||
| StatementKind::Coverage(_)
|
||||
| StatementKind::StorageDead(_)
|
||||
| StatementKind::CopyNonOverlapping(_)
|
||||
| StatementKind::Assume(_)
|
||||
| StatementKind::Nop => {}
|
||||
}
|
||||
}
|
||||
|
@ -318,6 +319,7 @@ fn find_determining_place<'tcx>(
|
|||
| StatementKind::AscribeUserType(_, _)
|
||||
| StatementKind::Coverage(_)
|
||||
| StatementKind::CopyNonOverlapping(_)
|
||||
| StatementKind::Assume(_)
|
||||
| StatementKind::Nop => {}
|
||||
|
||||
// If the discriminant is set, it is always set
|
||||
|
|
|
@ -500,6 +500,7 @@ impl<'tcx> Visitor<'tcx> for UsedLocals {
|
|||
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
||||
match statement.kind {
|
||||
StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assume(..)
|
||||
| StatementKind::Retag(..)
|
||||
| StatementKind::Coverage(..)
|
||||
| StatementKind::FakeRead(..)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue