Skip to content

Commit a34c079

Browse files
committed
Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieu
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2 parents 128417f + b085eb0 commit a34c079

File tree

171 files changed

+235
-3297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+235
-3297
lines changed

compiler/rustc_ast/src/ast.rs

+1-38
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ impl Expr {
12661266
ExprKind::Break(..) => ExprPrecedence::Break,
12671267
ExprKind::Continue(..) => ExprPrecedence::Continue,
12681268
ExprKind::Ret(..) => ExprPrecedence::Ret,
1269-
ExprKind::InlineAsm(..) | ExprKind::LlvmInlineAsm(..) => ExprPrecedence::InlineAsm,
1269+
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
12701270
ExprKind::MacCall(..) => ExprPrecedence::Mac,
12711271
ExprKind::Struct(..) => ExprPrecedence::Struct,
12721272
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
@@ -1423,8 +1423,6 @@ pub enum ExprKind {
14231423

14241424
/// Output of the `asm!()` macro.
14251425
InlineAsm(P<InlineAsm>),
1426-
/// Output of the `llvm_asm!()` macro.
1427-
LlvmInlineAsm(P<LlvmInlineAsm>),
14281426

14291427
/// A macro invocation; pre-expansion.
14301428
MacCall(MacCall),
@@ -2076,41 +2074,6 @@ pub struct InlineAsm {
20762074
pub line_spans: Vec<Span>,
20772075
}
20782076

2079-
/// Inline assembly dialect.
2080-
///
2081-
/// E.g., `"intel"` as in `llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
2082-
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy, Hash, HashStable_Generic)]
2083-
pub enum LlvmAsmDialect {
2084-
Att,
2085-
Intel,
2086-
}
2087-
2088-
/// LLVM-style inline assembly.
2089-
///
2090-
/// E.g., `"={eax}"(result)` as in `llvm_asm!("mov eax, 2" : "={eax}"(result) : : : "intel")`.
2091-
#[derive(Clone, Encodable, Decodable, Debug)]
2092-
pub struct LlvmInlineAsmOutput {
2093-
pub constraint: Symbol,
2094-
pub expr: P<Expr>,
2095-
pub is_rw: bool,
2096-
pub is_indirect: bool,
2097-
}
2098-
2099-
/// LLVM-style inline assembly.
2100-
///
2101-
/// E.g., `llvm_asm!("NOP");`.
2102-
#[derive(Clone, Encodable, Decodable, Debug)]
2103-
pub struct LlvmInlineAsm {
2104-
pub asm: Symbol,
2105-
pub asm_str_style: StrStyle,
2106-
pub outputs: Vec<LlvmInlineAsmOutput>,
2107-
pub inputs: Vec<(Symbol, P<Expr>)>,
2108-
pub clobbers: Vec<Symbol>,
2109-
pub volatile: bool,
2110-
pub alignstack: bool,
2111-
pub dialect: LlvmAsmDialect,
2112-
}
2113-
21142077
/// A parameter in a function header.
21152078
///
21162079
/// E.g., `bar: usize` as in `fn foo(bar: usize)`.

compiler/rustc_ast/src/mut_visit.rs

-17
Original file line numberDiff line numberDiff line change
@@ -1350,23 +1350,6 @@ pub fn noop_visit_expr<T: MutVisitor>(
13501350
visit_opt(expr, |expr| vis.visit_expr(expr));
13511351
}
13521352
ExprKind::InlineAsm(asm) => noop_visit_inline_asm(asm, vis),
1353-
ExprKind::LlvmInlineAsm(asm) => {
1354-
let LlvmInlineAsm {
1355-
asm: _,
1356-
asm_str_style: _,
1357-
outputs,
1358-
inputs,
1359-
clobbers: _,
1360-
volatile: _,
1361-
alignstack: _,
1362-
dialect: _,
1363-
} = asm.deref_mut();
1364-
for out in outputs {
1365-
let LlvmInlineAsmOutput { constraint: _, expr, is_rw: _, is_indirect: _ } = out;
1366-
vis.visit_expr(expr);
1367-
}
1368-
visit_vec(inputs, |(_c, expr)| vis.visit_expr(expr));
1369-
}
13701353
ExprKind::MacCall(mac) => vis.visit_mac_call(mac),
13711354
ExprKind::Struct(se) => {
13721355
let StructExpr { qself, path, fields, rest } = se.deref_mut();

compiler/rustc_ast/src/visit.rs

-8
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,6 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
864864
ExprKind::MacCall(ref mac) => visitor.visit_mac_call(mac),
865865
ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
866866
ExprKind::InlineAsm(ref asm) => walk_inline_asm(visitor, asm),
867-
ExprKind::LlvmInlineAsm(ref ia) => {
868-
for &(_, ref input) in &ia.inputs {
869-
visitor.visit_expr(input)
870-
}
871-
for output in &ia.outputs {
872-
visitor.visit_expr(&output.expr)
873-
}
874-
}
875867
ExprKind::Yield(ref optional_expression) => {
876868
walk_list!(visitor, visit_expr, optional_expression);
877869
}

compiler/rustc_ast_lowering/src/expr.rs

-33
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
226226
ExprKind::InlineAsm(ref asm) => {
227227
hir::ExprKind::InlineAsm(self.lower_inline_asm(e.span, asm))
228228
}
229-
ExprKind::LlvmInlineAsm(ref asm) => self.lower_expr_llvm_asm(asm),
230229
ExprKind::Struct(ref se) => {
231230
let rest = match &se.rest {
232231
StructRest::Base(e) => Some(self.lower_expr(e)),
@@ -1286,38 +1285,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
12861285
result
12871286
}
12881287

1289-
fn lower_expr_llvm_asm(&mut self, asm: &LlvmInlineAsm) -> hir::ExprKind<'hir> {
1290-
let inner = hir::LlvmInlineAsmInner {
1291-
inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
1292-
outputs: asm
1293-
.outputs
1294-
.iter()
1295-
.map(|out| hir::LlvmInlineAsmOutput {
1296-
constraint: out.constraint,
1297-
is_rw: out.is_rw,
1298-
is_indirect: out.is_indirect,
1299-
span: self.lower_span(out.expr.span),
1300-
})
1301-
.collect(),
1302-
asm: asm.asm,
1303-
asm_str_style: asm.asm_str_style,
1304-
clobbers: asm.clobbers.clone(),
1305-
volatile: asm.volatile,
1306-
alignstack: asm.alignstack,
1307-
dialect: asm.dialect,
1308-
};
1309-
let hir_asm = hir::LlvmInlineAsm {
1310-
inner,
1311-
inputs_exprs: self.arena.alloc_from_iter(
1312-
asm.inputs.iter().map(|&(_, ref input)| self.lower_expr_mut(input)),
1313-
),
1314-
outputs_exprs: self
1315-
.arena
1316-
.alloc_from_iter(asm.outputs.iter().map(|out| self.lower_expr_mut(&out.expr))),
1317-
};
1318-
hir::ExprKind::LlvmInlineAsm(self.arena.alloc(hir_asm))
1319-
}
1320-
13211288
fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
13221289
hir::ExprField {
13231290
hir_id: self.next_id(),

compiler/rustc_ast_passes/src/ast_validation.rs

-9
Original file line numberDiff line numberDiff line change
@@ -960,15 +960,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
960960
return;
961961
}
962962
ExprKind::Let(..) if !let_allowed => this.ban_let_expr(expr),
963-
ExprKind::LlvmInlineAsm(..) if !this.session.target.allow_asm => {
964-
struct_span_err!(
965-
this.session,
966-
expr.span,
967-
E0472,
968-
"llvm_asm! is unsupported on this target"
969-
)
970-
.emit();
971-
}
972963
ExprKind::Match(expr, arms) => {
973964
this.visit_expr(expr);
974965
for arm in arms {

compiler/rustc_ast_pretty/src/pprust/state.rs

-56
Original file line numberDiff line numberDiff line change
@@ -2168,62 +2168,6 @@ impl<'a> State<'a> {
21682168
self.word("asm!");
21692169
self.print_inline_asm(a);
21702170
}
2171-
ast::ExprKind::LlvmInlineAsm(ref a) => {
2172-
self.word("llvm_asm!");
2173-
self.popen();
2174-
self.print_symbol(a.asm, a.asm_str_style);
2175-
self.word_space(":");
2176-
2177-
self.commasep(Inconsistent, &a.outputs, |s, out| {
2178-
let constraint = out.constraint.as_str();
2179-
let mut ch = constraint.chars();
2180-
match ch.next() {
2181-
Some('=') if out.is_rw => {
2182-
s.print_string(&format!("+{}", ch.as_str()), ast::StrStyle::Cooked)
2183-
}
2184-
_ => s.print_string(&constraint, ast::StrStyle::Cooked),
2185-
}
2186-
s.popen();
2187-
s.print_expr(&out.expr);
2188-
s.pclose();
2189-
});
2190-
self.space();
2191-
self.word_space(":");
2192-
2193-
self.commasep(Inconsistent, &a.inputs, |s, &(co, ref o)| {
2194-
s.print_symbol(co, ast::StrStyle::Cooked);
2195-
s.popen();
2196-
s.print_expr(o);
2197-
s.pclose();
2198-
});
2199-
self.space();
2200-
self.word_space(":");
2201-
2202-
self.commasep(Inconsistent, &a.clobbers, |s, &co| {
2203-
s.print_symbol(co, ast::StrStyle::Cooked);
2204-
});
2205-
2206-
let mut options = vec![];
2207-
if a.volatile {
2208-
options.push("volatile");
2209-
}
2210-
if a.alignstack {
2211-
options.push("alignstack");
2212-
}
2213-
if a.dialect == ast::LlvmAsmDialect::Intel {
2214-
options.push("intel");
2215-
}
2216-
2217-
if !options.is_empty() {
2218-
self.space();
2219-
self.word_space(":");
2220-
self.commasep(Inconsistent, &options, |s, &co| {
2221-
s.print_string(co, ast::StrStyle::Cooked);
2222-
});
2223-
}
2224-
2225-
self.pclose();
2226-
}
22272171
ast::ExprKind::MacCall(ref m) => self.print_mac(m),
22282172
ast::ExprKind::Paren(ref e) => {
22292173
self.popen();

compiler/rustc_borrowck/src/dataflow.rs

-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_mir_dataflow::ResultsVisitable;
88
use rustc_mir_dataflow::{self, fmt::DebugWithContext, CallReturnPlaces, GenKill};
99
use rustc_mir_dataflow::{Analysis, Direction, Results};
1010
use std::fmt;
11-
use std::iter;
1211

1312
use crate::{
1413
places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, ToRegionVid,
@@ -385,14 +384,6 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
385384
self.kill_borrows_on_place(trans, Place::from(local));
386385
}
387386

388-
mir::StatementKind::LlvmInlineAsm(ref asm) => {
389-
for (output, kind) in iter::zip(&*asm.outputs, &asm.asm.outputs) {
390-
if !kind.is_indirect && !kind.is_rw {
391-
self.kill_borrows_on_place(trans, *output);
392-
}
393-
}
394-
}
395-
396387
mir::StatementKind::FakeRead(..)
397388
| mir::StatementKind::SetDiscriminant { .. }
398389
| mir::StatementKind::StorageLive(..)

compiler/rustc_borrowck/src/def_use.rs

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
1616

1717
PlaceContext::MutatingUse(MutatingUseContext::Store) |
1818

19-
// This is potentially both a def and a use...
20-
PlaceContext::MutatingUse(MutatingUseContext::LlvmAsmOutput) |
21-
2219
// We let Call define the result in both the success and
2320
// unwind cases. This is not really correct, however it
2421
// does not seem to be observable due to the way that we

compiler/rustc_borrowck/src/invalidation.rs

+10-41
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ use rustc_middle::mir::{BorrowKind, Mutability, Operand};
55
use rustc_middle::mir::{InlineAsmOperand, Terminator, TerminatorKind};
66
use rustc_middle::mir::{Statement, StatementKind};
77
use rustc_middle::ty::TyCtxt;
8-
use std::iter;
98

109
use crate::{
1110
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, path_utils::*, AccessDepth,
12-
Activation, ArtificialField, BorrowIndex, Deep, JustWrite, LocalMutationIsAllowed, MutateMode,
13-
Read, ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteAndRead, WriteKind,
11+
Activation, ArtificialField, BorrowIndex, Deep, LocalMutationIsAllowed, Read, ReadKind,
12+
ReadOrWrite, Reservation, Shallow, Write, WriteKind,
1413
};
1514

1615
pub(super) fn generate_invalidates<'tcx>(
@@ -59,37 +58,13 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
5958
StatementKind::Assign(box (lhs, rhs)) => {
6059
self.consume_rvalue(location, rhs);
6160

62-
self.mutate_place(location, *lhs, Shallow(None), JustWrite);
61+
self.mutate_place(location, *lhs, Shallow(None));
6362
}
6463
StatementKind::FakeRead(box (_, _)) => {
6564
// Only relevant for initialized/liveness/safety checks.
6665
}
6766
StatementKind::SetDiscriminant { place, variant_index: _ } => {
68-
self.mutate_place(location, **place, Shallow(None), JustWrite);
69-
}
70-
StatementKind::LlvmInlineAsm(asm) => {
71-
for (o, output) in iter::zip(&asm.asm.outputs, &*asm.outputs) {
72-
if o.is_indirect {
73-
// FIXME(eddyb) indirect inline asm outputs should
74-
// be encoded through MIR place derefs instead.
75-
self.access_place(
76-
location,
77-
*output,
78-
(Deep, Read(ReadKind::Copy)),
79-
LocalMutationIsAllowed::No,
80-
);
81-
} else {
82-
self.mutate_place(
83-
location,
84-
*output,
85-
if o.is_rw { Deep } else { Shallow(None) },
86-
if o.is_rw { WriteAndRead } else { JustWrite },
87-
);
88-
}
89-
}
90-
for (_, input) in asm.inputs.iter() {
91-
self.consume_operand(location, input);
92-
}
67+
self.mutate_place(location, **place, Shallow(None));
9368
}
9469
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
9570
ref src,
@@ -142,7 +117,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
142117
target: _,
143118
unwind: _,
144119
} => {
145-
self.mutate_place(location, *drop_place, Deep, JustWrite);
120+
self.mutate_place(location, *drop_place, Deep);
146121
self.consume_operand(location, new_value);
147122
}
148123
TerminatorKind::Call {
@@ -158,7 +133,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
158133
self.consume_operand(location, arg);
159134
}
160135
if let Some((dest, _ /*bb*/)) = destination {
161-
self.mutate_place(location, *dest, Deep, JustWrite);
136+
self.mutate_place(location, *dest, Deep);
162137
}
163138
}
164139
TerminatorKind::Assert { ref cond, expected: _, ref msg, target: _, cleanup: _ } => {
@@ -181,7 +156,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
181156
}
182157
}
183158

184-
self.mutate_place(location, *resume_arg, Deep, JustWrite);
159+
self.mutate_place(location, *resume_arg, Deep);
185160
}
186161
TerminatorKind::Resume | TerminatorKind::Return | TerminatorKind::GeneratorDrop => {
187162
// Invalidate all borrows of local places
@@ -208,13 +183,13 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
208183
}
209184
InlineAsmOperand::Out { reg: _, late: _, place, .. } => {
210185
if let Some(place) = place {
211-
self.mutate_place(location, place, Shallow(None), JustWrite);
186+
self.mutate_place(location, place, Shallow(None));
212187
}
213188
}
214189
InlineAsmOperand::InOut { reg: _, late: _, ref in_value, out_place } => {
215190
self.consume_operand(location, in_value);
216191
if let Some(out_place) = out_place {
217-
self.mutate_place(location, out_place, Shallow(None), JustWrite);
192+
self.mutate_place(location, out_place, Shallow(None));
218193
}
219194
}
220195
InlineAsmOperand::Const { value: _ }
@@ -238,13 +213,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
238213

239214
impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
240215
/// Simulates mutation of a place.
241-
fn mutate_place(
242-
&mut self,
243-
location: Location,
244-
place: Place<'tcx>,
245-
kind: AccessDepth,
246-
_mode: MutateMode,
247-
) {
216+
fn mutate_place(&mut self, location: Location, place: Place<'tcx>, kind: AccessDepth) {
248217
self.access_place(
249218
location,
250219
place,

0 commit comments

Comments
 (0)