Remove deprecated LLVM-style inline assembly
This commit is contained in:
parent
72e74d7b9c
commit
000b36c505
68 changed files with 27 additions and 1132 deletions
|
@ -104,10 +104,6 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
// safe (at least as emitted during MIR construction)
|
||||
}
|
||||
|
||||
StatementKind::LlvmInlineAsm { .. } => self.require_unsafe(
|
||||
UnsafetyViolationKind::General,
|
||||
UnsafetyViolationDetails::UseOfInlineAssembly,
|
||||
),
|
||||
StatementKind::CopyNonOverlapping(..) => unreachable!(),
|
||||
}
|
||||
self.super_statement(statement, location);
|
||||
|
@ -208,7 +204,6 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
|
|||
MutatingUseContext::Store
|
||||
| MutatingUseContext::Drop
|
||||
| MutatingUseContext::AsmOutput
|
||||
| MutatingUseContext::LlvmAsmOutput
|
||||
)
|
||||
);
|
||||
// If this is just an assignment, determine if the assigned type needs dropping.
|
||||
|
|
|
@ -1035,8 +1035,7 @@ impl Visitor<'_> for CanConstProp {
|
|||
|
||||
// These could be propagated with a smarter analysis or just some careful thinking about
|
||||
// whether they'd be fine right now.
|
||||
MutatingUse(MutatingUseContext::LlvmAsmOutput)
|
||||
| MutatingUse(MutatingUseContext::Yield)
|
||||
MutatingUse(MutatingUseContext::Yield)
|
||||
| MutatingUse(MutatingUseContext::Drop)
|
||||
| MutatingUse(MutatingUseContext::Retag)
|
||||
// These can't ever be propagated under any scheme, as we can't reason about indirect
|
||||
|
|
|
@ -835,7 +835,6 @@ pub(super) fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span>
|
|||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Assign(_)
|
||||
| StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::LlvmInlineAsm(_)
|
||||
| StatementKind::Retag(_, _)
|
||||
| StatementKind::AscribeUserType(_, _) => {
|
||||
Some(statement.source_info.span)
|
||||
|
|
|
@ -534,25 +534,6 @@ impl<'a> Conflicts<'a> {
|
|||
// eliminate the resulting self-assignments automatically.
|
||||
StatementKind::Assign(_) => {}
|
||||
|
||||
StatementKind::LlvmInlineAsm(asm) => {
|
||||
// Inputs and outputs must not overlap.
|
||||
for (_, input) in &*asm.inputs {
|
||||
if let Some(in_place) = input.place() {
|
||||
if !in_place.is_indirect() {
|
||||
for out_place in &*asm.outputs {
|
||||
if !out_place.is_indirect() && !in_place.is_indirect() {
|
||||
self.record_local_conflict(
|
||||
in_place.local,
|
||||
out_place.local,
|
||||
"aliasing llvm_asm! operands",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::StorageLive(..)
|
||||
| StatementKind::StorageDead(..)
|
||||
|
|
|
@ -1449,9 +1449,6 @@ impl<'tcx> Visitor<'tcx> for EnsureGeneratorFieldAssignmentsNeverAlias<'_> {
|
|||
self.check_assigned_place(*lhs, |this| this.visit_rvalue(rhs, location));
|
||||
}
|
||||
|
||||
// FIXME: Does `llvm_asm!` have any aliasing requirements?
|
||||
StatementKind::LlvmInlineAsm(_) => {}
|
||||
|
||||
StatementKind::FakeRead(..)
|
||||
| StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::StorageLive(_)
|
||||
|
|
|
@ -50,7 +50,6 @@ impl RemoveNoopLandingPads {
|
|||
|
||||
StatementKind::Assign { .. }
|
||||
| StatementKind::SetDiscriminant { .. }
|
||||
| StatementKind::LlvmInlineAsm { .. }
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Retag { .. } => {
|
||||
return false;
|
||||
|
|
|
@ -239,10 +239,6 @@ fn is_likely_const<'tcx>(mut tracked_place: Place<'tcx>, block: &BasicBlockData<
|
|||
}
|
||||
}
|
||||
|
||||
// If inline assembly is found, we probably should
|
||||
// not try to analyze the code
|
||||
StatementKind::LlvmInlineAsm(_) => return false,
|
||||
|
||||
// These statements have no influence on the place
|
||||
// we are interested in
|
||||
StatementKind::FakeRead(_)
|
||||
|
@ -320,10 +316,6 @@ fn find_determining_place<'tcx>(
|
|||
| StatementKind::CopyNonOverlapping(_)
|
||||
| StatementKind::Nop => {}
|
||||
|
||||
// If inline assembly is found, we probably should
|
||||
// not try to analyze the code
|
||||
StatementKind::LlvmInlineAsm(_) => return None,
|
||||
|
||||
// If the discriminant is set, it is always set
|
||||
// as a constant, so the job is already done.
|
||||
// As we are **ignoring projections**, if the place
|
||||
|
|
|
@ -483,8 +483,7 @@ impl UsedLocals {
|
|||
impl<'tcx> Visitor<'tcx> for UsedLocals {
|
||||
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
||||
match statement.kind {
|
||||
StatementKind::LlvmInlineAsm(..)
|
||||
| StatementKind::CopyNonOverlapping(..)
|
||||
StatementKind::CopyNonOverlapping(..)
|
||||
| StatementKind::Retag(..)
|
||||
| StatementKind::Coverage(..)
|
||||
| StatementKind::FakeRead(..)
|
||||
|
|
|
@ -631,10 +631,6 @@ impl<'tcx> SimplifyBranchSameOptimizationFinder<'_, 'tcx> {
|
|||
.filter(|(_, bb)| {
|
||||
// Reaching `unreachable` is UB so assume it doesn't happen.
|
||||
bb.terminator().kind != TerminatorKind::Unreachable
|
||||
// But `asm!(...)` could abort the program,
|
||||
// so we cannot assume that the `unreachable` terminator itself is reachable.
|
||||
// FIXME(Centril): use a normalization pass instead of a check.
|
||||
|| bb.statements.iter().any(|stmt| matches!(stmt.kind, StatementKind::LlvmInlineAsm(..)))
|
||||
})
|
||||
.peekable();
|
||||
|
||||
|
|
|
@ -23,23 +23,14 @@ impl MirPass<'_> for UnreachablePropagation {
|
|||
|
||||
for (bb, bb_data) in traversal::postorder(body) {
|
||||
let terminator = bb_data.terminator();
|
||||
// HACK: If the block contains any asm statement it is not regarded as unreachable.
|
||||
// This is a temporary solution that handles possibly diverging asm statements.
|
||||
// Accompanying testcases: mir-opt/unreachable_asm.rs and mir-opt/unreachable_asm_2.rs
|
||||
let asm_stmt_in_block = || {
|
||||
bb_data.statements.iter().any(|stmt: &Statement<'_>| {
|
||||
matches!(stmt.kind, StatementKind::LlvmInlineAsm(..))
|
||||
})
|
||||
};
|
||||
|
||||
if terminator.kind == TerminatorKind::Unreachable && !asm_stmt_in_block() {
|
||||
if terminator.kind == TerminatorKind::Unreachable {
|
||||
unreachable_blocks.insert(bb);
|
||||
} else {
|
||||
let is_unreachable = |succ: BasicBlock| unreachable_blocks.contains(&succ);
|
||||
let terminator_kind_opt = remove_successors(&terminator.kind, is_unreachable);
|
||||
|
||||
if let Some(terminator_kind) = terminator_kind_opt {
|
||||
if terminator_kind == TerminatorKind::Unreachable && !asm_stmt_in_block() {
|
||||
if terminator_kind == TerminatorKind::Unreachable {
|
||||
unreachable_blocks.insert(bb);
|
||||
}
|
||||
replacements.insert(bb, terminator_kind);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue