From 48abe3c6fa29dbedc611e22c6acde7d0022219f4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 10 Jan 2022 15:32:45 +0100 Subject: [PATCH 1/2] Use Symbol for target features in asm handling This saves a couple of Symbol::intern calls --- src/inline_asm.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 93384bc5511..be39dbd2e2a 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -6,7 +6,7 @@ use std::fmt::Write; use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_middle::mir::InlineAsmOperand; -use rustc_span::Symbol; +use rustc_span::sym; use rustc_target::asm::*; pub(crate) fn codegen_inline_asm<'tcx>( @@ -184,7 +184,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { let sess = self.tcx.sess; let map = allocatable_registers( self.arch, - |feature| sess.target_features.contains(&Symbol::intern(feature)), + |feature| sess.target_features.contains(&feature), &sess.target, ); let mut allocated = FxHashMap::<_, (bool, bool)>::default(); @@ -319,9 +319,9 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { // Allocate stack slots for saving clobbered registers let abi_clobber = InlineAsmClobberAbi::parse( self.arch, - |feature| self.tcx.sess.target_features.contains(&Symbol::intern(feature)), + |feature| self.tcx.sess.target_features.contains(&feature), &self.tcx.sess.target, - Symbol::intern("C"), + sym::C, ) .unwrap() .clobbered_regs(); From e59b024e025795ecf7e3a57471451996be637656 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 10 Jan 2022 15:48:05 +0100 Subject: [PATCH 2/2] Pass target_features set instead of has_feature closure This avoids unnecessary monomorphizations in codegen backends --- src/inline_asm.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/inline_asm.rs b/src/inline_asm.rs index be39dbd2e2a..c242c75ed18 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -182,11 +182,7 @@ struct InlineAssemblyGenerator<'a, 'tcx> { impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { fn allocate_registers(&mut self) { let sess = self.tcx.sess; - let map = allocatable_registers( - self.arch, - |feature| sess.target_features.contains(&feature), - &sess.target, - ); + let map = allocatable_registers(self.arch, &sess.target_features, &sess.target); let mut allocated = FxHashMap::<_, (bool, bool)>::default(); let mut regs = vec![None; self.operands.len()]; @@ -319,7 +315,7 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> { // Allocate stack slots for saving clobbered registers let abi_clobber = InlineAsmClobberAbi::parse( self.arch, - |feature| self.tcx.sess.target_features.contains(&feature), + &self.tcx.sess.target_features, &self.tcx.sess.target, sym::C, )