Properly check target_features
not to trigger an assertion
This commit is contained in:
parent
bd309e4628
commit
12647eab79
4 changed files with 11 additions and 4 deletions
|
@ -118,7 +118,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, _span: &[Span]) {
|
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, _span: &[Span], _instance: Instance<'_>) {
|
||||||
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
||||||
let is_x86 = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64);
|
let is_x86 = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64);
|
||||||
let att_dialect = is_x86 && options.contains(InlineAsmOptions::ATT_SYNTAX);
|
let att_dialect = is_x86 && options.contains(InlineAsmOptions::ATT_SYNTAX);
|
||||||
|
|
|
@ -13,7 +13,7 @@ use rustc_codegen_ssa::traits::*;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::ty::layout::TyAndLayout;
|
use rustc_middle::ty::layout::TyAndLayout;
|
||||||
use rustc_middle::{bug, span_bug};
|
use rustc_middle::{bug, span_bug, ty::Instance};
|
||||||
use rustc_span::{Pos, Span, Symbol};
|
use rustc_span::{Pos, Span, Symbol};
|
||||||
use rustc_target::abi::*;
|
use rustc_target::abi::*;
|
||||||
use rustc_target::asm::*;
|
use rustc_target::asm::*;
|
||||||
|
@ -120,6 +120,7 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
operands: &[InlineAsmOperandRef<'tcx, Self>],
|
operands: &[InlineAsmOperandRef<'tcx, Self>],
|
||||||
options: InlineAsmOptions,
|
options: InlineAsmOptions,
|
||||||
line_spans: &[Span],
|
line_spans: &[Span],
|
||||||
|
instance: Instance<'_>,
|
||||||
) {
|
) {
|
||||||
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
let asm_arch = self.tcx.sess.asm_arch.unwrap();
|
||||||
|
|
||||||
|
@ -135,7 +136,10 @@ impl AsmBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
|
||||||
let is_target_supported = |reg_class: InlineAsmRegClass| {
|
let is_target_supported = |reg_class: InlineAsmRegClass| {
|
||||||
for &(_, feature) in reg_class.supported_types(asm_arch) {
|
for &(_, feature) in reg_class.supported_types(asm_arch) {
|
||||||
if let Some(feature) = feature {
|
if let Some(feature) = feature {
|
||||||
if self.tcx.sess.target_features.contains(&Symbol::intern(feature))
|
let codegen_fn_attrs = self.tcx.codegen_fn_attrs(instance.def_id());
|
||||||
|
let feature_name = Symbol::intern(feature);
|
||||||
|
if self.tcx.sess.target_features.contains(&feature_name)
|
||||||
|
|| codegen_fn_attrs.target_features.contains(&feature_name)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -845,6 +845,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
options: ast::InlineAsmOptions,
|
options: ast::InlineAsmOptions,
|
||||||
line_spans: &[Span],
|
line_spans: &[Span],
|
||||||
destination: Option<mir::BasicBlock>,
|
destination: Option<mir::BasicBlock>,
|
||||||
|
instance: Instance<'_>,
|
||||||
) {
|
) {
|
||||||
let span = terminator.source_info.span;
|
let span = terminator.source_info.span;
|
||||||
|
|
||||||
|
@ -898,7 +899,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
bx.codegen_inline_asm(template, &operands, options, line_spans);
|
bx.codegen_inline_asm(template, &operands, options, line_spans, instance);
|
||||||
|
|
||||||
if let Some(target) = destination {
|
if let Some(target) = destination {
|
||||||
helper.funclet_br(self, &mut bx, target);
|
helper.funclet_br(self, &mut bx, target);
|
||||||
|
@ -1029,6 +1030,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
options,
|
options,
|
||||||
line_spans,
|
line_spans,
|
||||||
destination,
|
destination,
|
||||||
|
self.instance,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
||||||
operands: &[InlineAsmOperandRef<'tcx, Self>],
|
operands: &[InlineAsmOperandRef<'tcx, Self>],
|
||||||
options: InlineAsmOptions,
|
options: InlineAsmOptions,
|
||||||
line_spans: &[Span],
|
line_spans: &[Span],
|
||||||
|
instance: Instance<'_>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue