Skip to content

Commit

Permalink
Use Cow instead of &[] for InlineAsm MIR
Browse files Browse the repository at this point in the history
Fixes #72386
  • Loading branch information
Amanieu committed May 20, 2020
1 parent f182c4a commit 969da62
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
bug!("borrowck false edges in codegen")
}

mir::TerminatorKind::InlineAsm { template, ref operands, options, destination } => {
mir::TerminatorKind::InlineAsm { ref template, ref operands, options, destination } => {
self.codegen_asm_terminator(
helper,
bx,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ pub enum TerminatorKind<'tcx> {
/// inline assembly is allowed to diverge.
InlineAsm {
/// The template for the inline assembly, with placeholders.
template: &'tcx [InlineAsmTemplatePiece],
template: Cow<'tcx, [InlineAsmTemplatePiece]>,

/// The operands for the inline assembly, as `Operand`s or `Place`s.
operands: Vec<InlineAsmOperand<'tcx>>,
Expand Down
9 changes: 6 additions & 3 deletions src/librustc_middle/mir/type_foldable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
FalseEdges { real_target, imaginary_target }
}
FalseUnwind { real_target, unwind } => FalseUnwind { real_target, unwind },
InlineAsm { template, ref operands, options, destination } => {
InlineAsm { template, operands: operands.fold_with(folder), options, destination }
}
InlineAsm { ref template, ref operands, options, destination } => InlineAsm {
template: template.clone(),
operands: operands.fold_with(folder),
options,
destination,
},
};
Terminator { source_info: self.source_info, kind }
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block,
source_info,
TerminatorKind::InlineAsm {
template,
template: template.into(),
operands,
options,
destination: if options.contains(InlineAsmOptions::NORETURN) {
Expand Down

0 comments on commit 969da62

Please sign in to comment.