Skip to content

Commit c1699a7

Browse files
committed
Auto merge of #114467 - Amanieu:asm-unstable-features, r=davidtwco
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.
2 parents fd9525a + a3ab31c commit c1699a7

File tree

2 files changed

+6
-5
lines changed
  • compiler

2 files changed

+6
-5
lines changed

compiler/rustc_codegen_gcc/src/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ enum ConstraintOrRegister {
107107

108108

109109
impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
110-
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>)>) {
110+
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>)>) {
111111
if options.contains(InlineAsmOptions::MAY_UNWIND) {
112112
self.sess()
113113
.create_err(UnwindingInlineAsm { span: span[0] })
@@ -173,7 +173,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
173173
let is_target_supported = reg.reg_class().supported_types(asm_arch).iter()
174174
.any(|&(_, feature)| {
175175
if let Some(feature) = feature {
176-
self.tcx.sess.target_features.contains(&feature)
176+
self.tcx.asm_target_features(instance.def_id()).contains(&feature)
177177
} else {
178178
true // Register class is unconditionally supported
179179
}

compiler/rustc_codegen_llvm/src/asm.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
4444
let is_target_supported = |reg_class: InlineAsmRegClass| {
4545
for &(_, feature) in reg_class.supported_types(asm_arch) {
4646
if let Some(feature) = feature {
47-
let codegen_fn_attrs = self.tcx.codegen_fn_attrs(instance.def_id());
48-
if self.tcx.sess.target_features.contains(&feature)
49-
|| codegen_fn_attrs.target_features.contains(&feature)
47+
if self
48+
.tcx
49+
.asm_target_features(instance.def_id())
50+
.contains(&feature)
5051
{
5152
return true;
5253
}

0 commit comments

Comments
 (0)