Use unstable_target_features when checking inline assembly

This is necessary to properly validate register classes even when the
relevant target feature name is still unstable.
This commit is contained in:
Amanieu d'Antras 2023-08-04 16:09:54 +01:00
parent 4bebfae44a
commit 913fcf50ee

View File

@ -107,7 +107,7 @@ enum ConstraintOrRegister {
impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], _instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) { fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) {
if options.contains(InlineAsmOptions::MAY_UNWIND) { if options.contains(InlineAsmOptions::MAY_UNWIND) {
self.sess() self.sess()
.create_err(UnwindingInlineAsm { span: span[0] }) .create_err(UnwindingInlineAsm { span: span[0] })
@ -173,7 +173,7 @@ fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_opera
let is_target_supported = reg.reg_class().supported_types(asm_arch).iter() let is_target_supported = reg.reg_class().supported_types(asm_arch).iter()
.any(|&(_, feature)| { .any(|&(_, feature)| {
if let Some(feature) = feature { if let Some(feature) = feature {
self.tcx.sess.target_features.contains(&feature) self.tcx.asm_target_features(instance.def_id()).contains(&feature)
} else { } else {
true // Register class is unconditionally supported true // Register class is unconditionally supported
} }