From 969da62fdb2a40fc9a54704c31b3aa2638ee711c Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Wed, 20 May 2020 19:24:23 +0100 Subject: [PATCH] Use Cow instead of &[] for InlineAsm MIR Fixes #72386 --- src/librustc_codegen_ssa/mir/block.rs | 2 +- src/librustc_middle/mir/mod.rs | 2 +- src/librustc_middle/mir/type_foldable.rs | 9 ++++++--- src/librustc_mir_build/build/expr/into.rs | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index b487ed8dea8b6..d74114b7f3bb8 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -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, diff --git a/src/librustc_middle/mir/mod.rs b/src/librustc_middle/mir/mod.rs index 8247338ae0fad..51d2b1037255b 100644 --- a/src/librustc_middle/mir/mod.rs +++ b/src/librustc_middle/mir/mod.rs @@ -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>, diff --git a/src/librustc_middle/mir/type_foldable.rs b/src/librustc_middle/mir/type_foldable.rs index bb7001c1207bf..012e0f2b90e36 100644 --- a/src/librustc_middle/mir/type_foldable.rs +++ b/src/librustc_middle/mir/type_foldable.rs @@ -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 } } diff --git a/src/librustc_mir_build/build/expr/into.rs b/src/librustc_mir_build/build/expr/into.rs index ff3c7ee3ee823..75c0f4b855e12 100644 --- a/src/librustc_mir_build/build/expr/into.rs +++ b/src/librustc_mir_build/build/expr/into.rs @@ -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) {