Skip to content

Commit db2cd0e

Browse files
committed
EXPERIMENT: measure asm!'s complexity by removing it.
1 parent 0f0c640 commit db2cd0e

Some content is hidden

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

49 files changed

+17
-1143
lines changed

src/librustc/hir/intravisit.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,6 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
10861086
ExprKind::Ret(ref optional_expression) => {
10871087
walk_list!(visitor, visit_expr, optional_expression);
10881088
}
1089-
ExprKind::InlineAsm(_, ref outputs, ref inputs) => {
1090-
for expr in outputs.iter().chain(inputs.iter()) {
1091-
visitor.visit_expr(expr)
1092-
}
1093-
}
10941089
ExprKind::Yield(ref subexpression, _) => {
10951090
visitor.visit_expr(subexpression);
10961091
}

src/librustc/hir/lowering/expr.rs

-34
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ impl LoweringContext<'_> {
150150
hir::ExprKind::Continue(self.lower_jump_destination(e.id, opt_label))
151151
}
152152
ExprKind::Ret(ref e) => hir::ExprKind::Ret(e.as_ref().map(|x| P(self.lower_expr(x)))),
153-
ExprKind::InlineAsm(ref asm) => self.lower_expr_asm(asm),
154153
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => hir::ExprKind::Struct(
155154
P(self.lower_qpath(
156155
e.id,
@@ -965,39 +964,6 @@ impl LoweringContext<'_> {
965964
result
966965
}
967966

968-
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
969-
let hir_asm = hir::InlineAsm {
970-
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
971-
outputs: asm.outputs
972-
.iter()
973-
.map(|out| hir::InlineAsmOutput {
974-
constraint: out.constraint.clone(),
975-
is_rw: out.is_rw,
976-
is_indirect: out.is_indirect,
977-
span: out.expr.span,
978-
})
979-
.collect(),
980-
asm: asm.asm.clone(),
981-
asm_str_style: asm.asm_str_style,
982-
clobbers: asm.clobbers.clone().into(),
983-
volatile: asm.volatile,
984-
alignstack: asm.alignstack,
985-
dialect: asm.dialect,
986-
};
987-
988-
let outputs = asm.outputs
989-
.iter()
990-
.map(|out| self.lower_expr(&out.expr))
991-
.collect();
992-
993-
let inputs = asm.inputs
994-
.iter()
995-
.map(|&(_, ref input)| self.lower_expr(input))
996-
.collect();
997-
998-
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
999-
}
1000-
1001967
fn lower_field(&mut self, f: &Field) -> hir::Field {
1002968
hir::Field {
1003969
hir_id: self.next_id(),

src/librustc/hir/mod.rs

+3-30
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::util::nodemap::{NodeMap, FxHashSet};
1919
use errors::FatalError;
2020
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
2121
use syntax::source_map::Spanned;
22-
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
23-
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
22+
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId};
23+
use syntax::ast::{Attribute, Label, LitKind, FloatTy, IntTy, UintTy};
2424
pub use syntax::ast::{Mutability, Constness, Unsafety, Movability, CaptureBy, IsAuto, ImplPolarity};
2525
use syntax::attr::{InlineAttr, OptimizeAttr};
2626
use syntax::symbol::{Symbol, kw};
@@ -1457,7 +1457,7 @@ pub struct Expr {
14571457

14581458
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
14591459
#[cfg(target_arch = "x86_64")]
1460-
static_assert_size!(Expr, 72);
1460+
static_assert_size!(Expr, 64);
14611461

14621462
impl Expr {
14631463
pub fn precedence(&self) -> ExprPrecedence {
@@ -1485,7 +1485,6 @@ impl Expr {
14851485
ExprKind::Break(..) => ExprPrecedence::Break,
14861486
ExprKind::Continue(..) => ExprPrecedence::Continue,
14871487
ExprKind::Ret(..) => ExprPrecedence::Ret,
1488-
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
14891488
ExprKind::Struct(..) => ExprPrecedence::Struct,
14901489
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
14911490
ExprKind::Yield(..) => ExprPrecedence::Yield,
@@ -1532,7 +1531,6 @@ impl Expr {
15321531
ExprKind::Ret(..) |
15331532
ExprKind::Loop(..) |
15341533
ExprKind::Assign(..) |
1535-
ExprKind::InlineAsm(..) |
15361534
ExprKind::AssignOp(..) |
15371535
ExprKind::Lit(_) |
15381536
ExprKind::Unary(..) |
@@ -1655,9 +1653,6 @@ pub enum ExprKind {
16551653
/// A `return`, with an optional value to be returned.
16561654
Ret(Option<P<Expr>>),
16571655

1658-
/// Inline assembly (from `asm!`), with its outputs and inputs.
1659-
InlineAsm(P<InlineAsm>, HirVec<Expr>, HirVec<Expr>),
1660-
16611656
/// A struct or struct-like variant literal expression.
16621657
///
16631658
/// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. base}`,
@@ -2052,28 +2047,6 @@ pub enum TyKind {
20522047
Err,
20532048
}
20542049

2055-
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
2056-
pub struct InlineAsmOutput {
2057-
pub constraint: Symbol,
2058-
pub is_rw: bool,
2059-
pub is_indirect: bool,
2060-
pub span: Span,
2061-
}
2062-
2063-
// NOTE(eddyb) This is used within MIR as well, so unlike the rest of the HIR,
2064-
// it needs to be `Clone` and use plain `Vec<T>` instead of `HirVec<T>`.
2065-
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
2066-
pub struct InlineAsm {
2067-
pub asm: Symbol,
2068-
pub asm_str_style: StrStyle,
2069-
pub outputs: Vec<InlineAsmOutput>,
2070-
pub inputs: Vec<Symbol>,
2071-
pub clobbers: Vec<Symbol>,
2072-
pub volatile: bool,
2073-
pub alignstack: bool,
2074-
pub dialect: AsmDialect,
2075-
}
2076-
20772050
/// Represents a parameter in a function header.
20782051
#[derive(RustcEncodable, RustcDecodable, Debug, HashStable)]
20792052
pub struct Param {

src/librustc/hir/print.rs

-62
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use crate::hir::ptr::P;
1616

1717
use std::borrow::Cow;
1818
use std::cell::Cell;
19-
use std::vec;
2019

2120
pub enum AnnNode<'a> {
2221
Name(&'a ast::Name),
@@ -1365,67 +1364,6 @@ impl<'a> State<'a> {
13651364
self.print_expr_maybe_paren(&expr, parser::PREC_JUMP);
13661365
}
13671366
}
1368-
hir::ExprKind::InlineAsm(ref a, ref outputs, ref inputs) => {
1369-
self.s.word("asm!");
1370-
self.popen();
1371-
self.print_string(&a.asm.as_str(), a.asm_str_style);
1372-
self.word_space(":");
1373-
1374-
let mut out_idx = 0;
1375-
self.commasep(Inconsistent, &a.outputs, |s, out| {
1376-
let constraint = out.constraint.as_str();
1377-
let mut ch = constraint.chars();
1378-
match ch.next() {
1379-
Some('=') if out.is_rw => {
1380-
s.print_string(&format!("+{}", ch.as_str()),
1381-
ast::StrStyle::Cooked)
1382-
}
1383-
_ => s.print_string(&constraint, ast::StrStyle::Cooked),
1384-
}
1385-
s.popen();
1386-
s.print_expr(&outputs[out_idx]);
1387-
s.pclose();
1388-
out_idx += 1;
1389-
});
1390-
self.s.space();
1391-
self.word_space(":");
1392-
1393-
let mut in_idx = 0;
1394-
self.commasep(Inconsistent, &a.inputs, |s, co| {
1395-
s.print_string(&co.as_str(), ast::StrStyle::Cooked);
1396-
s.popen();
1397-
s.print_expr(&inputs[in_idx]);
1398-
s.pclose();
1399-
in_idx += 1;
1400-
});
1401-
self.s.space();
1402-
self.word_space(":");
1403-
1404-
self.commasep(Inconsistent, &a.clobbers, |s, co| {
1405-
s.print_string(&co.as_str(), ast::StrStyle::Cooked);
1406-
});
1407-
1408-
let mut options = vec![];
1409-
if a.volatile {
1410-
options.push("volatile");
1411-
}
1412-
if a.alignstack {
1413-
options.push("alignstack");
1414-
}
1415-
if a.dialect == ast::AsmDialect::Intel {
1416-
options.push("intel");
1417-
}
1418-
1419-
if !options.is_empty() {
1420-
self.s.space();
1421-
self.word_space(":");
1422-
self.commasep(Inconsistent, &options, |s, &co| {
1423-
s.print_string(co, ast::StrStyle::Cooked);
1424-
});
1425-
}
1426-
1427-
self.pclose();
1428-
}
14291367
hir::ExprKind::Yield(ref expr, _) => {
14301368
self.word_space("yield");
14311369
self.print_expr_maybe_paren(&expr, parser::PREC_JUMP);

src/librustc/ich/impls_syntax.rs

-5
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ impl<'a> ToStableHashKey<StableHashingContext<'a>> for ast::Name {
5555
}
5656
}
5757

58-
impl_stable_hash_for!(enum ::syntax::ast::AsmDialect {
59-
Att,
60-
Intel
61-
});
62-
6358
impl_stable_hash_for!(enum ::syntax_pos::hygiene::MacroKind {
6459
Bang,
6560
Attr,

src/librustc/middle/expr_use_visitor.rs

-11
Original file line numberDiff line numberDiff line change
@@ -283,17 +283,6 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
283283
self.borrow_expr(&base, bk);
284284
}
285285

286-
hir::ExprKind::InlineAsm(ref ia, ref outputs, ref inputs) => {
287-
for (o, output) in ia.outputs.iter().zip(outputs) {
288-
if o.is_indirect {
289-
self.consume_expr(output);
290-
} else {
291-
self.mutate_expr(output);
292-
}
293-
}
294-
self.consume_exprs(inputs);
295-
}
296-
297286
hir::ExprKind::Continue(..) |
298287
hir::ExprKind::Lit(..) |
299288
hir::ExprKind::Err => {}

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
619619
hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) |
620620
hir::ExprKind::Lit(..) | hir::ExprKind::Break(..) |
621621
hir::ExprKind::Continue(..) | hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) |
622-
hir::ExprKind::InlineAsm(..) | hir::ExprKind::Box(..) | hir::ExprKind::Err => {
622+
hir::ExprKind::Box(..) | hir::ExprKind::Err => {
623623
Ok(self.cat_rvalue_node(expr.hir_id, expr.span, expr_ty))
624624
}
625625
}

src/librustc/mir/mod.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use crate::hir::def::{CtorKind, Namespace};
88
use crate::hir::def_id::DefId;
9-
use crate::hir::{self, InlineAsm as HirInlineAsm};
9+
use crate::hir;
1010
use crate::mir::interpret::{PanicInfo, Scalar};
1111
use crate::mir::visit::MirVisitable;
1212
use crate::ty::adjustment::PointerCast;
@@ -1592,10 +1592,6 @@ pub enum StatementKind<'tcx> {
15921592
/// End the current live range for the storage of the local.
15931593
StorageDead(Local),
15941594

1595-
/// Executes a piece of inline Assembly. Stored in a Box to keep the size
1596-
/// of `StatementKind` low.
1597-
InlineAsm(Box<InlineAsm<'tcx>>),
1598-
15991595
/// Retag references in the given place, ensuring they got fresh tags. This is
16001596
/// part of the Stacked Borrows model. These statements are currently only interpreted
16011597
/// by miri and only generated when "-Z mir-emit-retag" is passed.
@@ -1677,13 +1673,6 @@ pub enum FakeReadCause {
16771673
ForIndex,
16781674
}
16791675

1680-
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
1681-
pub struct InlineAsm<'tcx> {
1682-
pub asm: HirInlineAsm,
1683-
pub outputs: Box<[Place<'tcx>]>,
1684-
pub inputs: Box<[(Span, Operand<'tcx>)]>,
1685-
}
1686-
16871676
impl Debug for Statement<'_> {
16881677
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
16891678
use self::StatementKind::*;
@@ -1706,9 +1695,6 @@ impl Debug for Statement<'_> {
17061695
SetDiscriminant { ref place, variant_index } => {
17071696
write!(fmt, "discriminant({:?}) = {:?}", place, variant_index)
17081697
}
1709-
InlineAsm(ref asm) => {
1710-
write!(fmt, "asm!({:?} : {:?} : {:?})", asm.asm, asm.outputs, asm.inputs)
1711-
}
17121698
AscribeUserType(box(ref place, ref c_ty), ref variance) => {
17131699
write!(fmt, "AscribeUserType({:?}, {:?}, {:?})", place, variance, c_ty)
17141700
}

src/librustc/mir/visit.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -359,19 +359,6 @@ macro_rules! make_mir_visitor {
359359
location
360360
);
361361
}
362-
StatementKind::InlineAsm(asm) => {
363-
for output in & $($mutability)? asm.outputs[..] {
364-
self.visit_place(
365-
output,
366-
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput),
367-
location
368-
);
369-
}
370-
for (span, input) in & $($mutability)? asm.inputs[..] {
371-
self.visit_span(span);
372-
self.visit_operand(input, location);
373-
}
374-
}
375362
StatementKind::Retag(kind, place) => {
376363
self.visit_retag(kind, place, location);
377364
}
@@ -1000,10 +987,6 @@ pub enum NonMutatingUseContext {
1000987
pub enum MutatingUseContext {
1001988
/// Appears as LHS of an assignment.
1002989
Store,
1003-
/// Can often be treated as a `Store`, but needs to be separate because
1004-
/// ASM is allowed to read outputs as well, so a `Store`-`AsmOutput` sequence
1005-
/// cannot be simplified the way a `Store`-`Store` can be.
1006-
AsmOutput,
1007990
/// Destination of a call.
1008991
Call,
1009992
/// Being dropped.
@@ -1111,8 +1094,7 @@ impl PlaceContext {
11111094
pub fn is_place_assignment(&self) -> bool {
11121095
match *self {
11131096
PlaceContext::MutatingUse(MutatingUseContext::Store) |
1114-
PlaceContext::MutatingUse(MutatingUseContext::Call) |
1115-
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) => true,
1097+
PlaceContext::MutatingUse(MutatingUseContext::Call) => true,
11161098
_ => false,
11171099
}
11181100
}

src/librustc/ty/structural_impls.rs

-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ CloneTypeFoldableAndLiftImpls! {
302302
::syntax_pos::symbol::Symbol,
303303
crate::hir::def::Res,
304304
crate::hir::def_id::DefId,
305-
crate::hir::InlineAsm,
306305
crate::hir::MatchSource,
307306
crate::hir::Mutability,
308307
crate::hir::Unsafety,

0 commit comments

Comments
 (0)