Skip to content

Commit ee8bc5b

Browse files
Use FxIndexSet instead of FxHashSet for asm_target_features query.
1 parent b0202d9 commit ee8bc5b

File tree

10 files changed

+39
-37
lines changed

10 files changed

+39
-37
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_ast::ast;
22
use rustc_attr::InstructionSetAttr;
33
use rustc_data_structures::fx::FxHashMap;
4-
use rustc_data_structures::fx::FxHashSet;
4+
use rustc_data_structures::fx::FxIndexSet;
55
use rustc_errors::Applicability;
66
use rustc_hir::def::DefKind;
77
use rustc_hir::def_id::DefId;
@@ -418,7 +418,7 @@ pub fn from_target_feature(
418418

419419
/// Computes the set of target features used in a function for the purposes of
420420
/// inline assembly.
421-
fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxHashSet<Symbol> {
421+
fn asm_target_features(tcx: TyCtxt<'_>, did: DefId) -> &FxIndexSet<Symbol> {
422422
let mut target_features = tcx.sess.unstable_target_features.clone();
423423
if tcx.def_kind(did).has_codegen_attrs() {
424424
let attrs = tcx.codegen_fn_attrs(did);

compiler/rustc_hir_analysis/src/check/intrinsicck.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_ast::InlineAsmTemplatePiece;
2-
use rustc_data_structures::fx::FxHashSet;
2+
use rustc_data_structures::fx::FxIndexSet;
33
use rustc_hir as hir;
44
use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy};
55
use rustc_session::lint;
@@ -51,7 +51,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
5151
template: &[InlineAsmTemplatePiece],
5252
is_input: bool,
5353
tied_input: Option<(&'tcx hir::Expr<'tcx>, Option<InlineAsmType>)>,
54-
target_features: &FxHashSet<Symbol>,
54+
target_features: &FxIndexSet<Symbol>,
5555
) -> Option<InlineAsmType> {
5656
let ty = (self.get_operand_ty)(expr);
5757
if ty.has_non_region_infer() {
@@ -201,7 +201,7 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> {
201201
// (!). In that case we still need the earlier check to verify that the
202202
// register class is usable at all.
203203
if let Some(feature) = feature {
204-
if !target_features.contains(&feature) {
204+
if !target_features.contains(feature) {
205205
let msg = &format!("`{}` target feature is not enabled", feature);
206206
let mut err = self.tcx.sess.struct_span_err(expr.span, msg);
207207
err.note(&format!(

compiler/rustc_middle/src/arena.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ macro_rules! arena_types {
9494
[] object_safety_violations: rustc_middle::traits::ObjectSafetyViolation,
9595
[] codegen_unit: rustc_middle::mir::mono::CodegenUnit<'tcx>,
9696
[decode] attribute: rustc_ast::Attribute,
97-
[] name_set: rustc_data_structures::fx::FxHashSet<rustc_span::symbol::Symbol>,
97+
[] name_set: rustc_data_structures::unord::UnordSet<rustc_span::symbol::Symbol>,
98+
[] ordered_name_set: rustc_data_structures::fx::FxIndexSet<rustc_span::symbol::Symbol>,
9899
[] hir_id_set: rustc_hir::HirIdSet,
99100

100101
// Interned types

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ rustc_queries! {
12121212
separate_provide_extern
12131213
}
12141214

1215-
query asm_target_features(def_id: DefId) -> &'tcx FxHashSet<Symbol> {
1215+
query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet<Symbol> {
12161216
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
12171217
}
12181218

compiler/rustc_session/src/session.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{filesearch, lint};
1111
pub use rustc_ast::attr::MarkedAttrs;
1212
pub use rustc_ast::Attribute;
1313
use rustc_data_structures::flock;
14-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
14+
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1515
use rustc_data_structures::jobserver::{self, Client};
1616
use rustc_data_structures::profiling::{duration_to_secs_str, SelfProfiler, SelfProfilerRef};
1717
use rustc_data_structures::sync::{
@@ -207,10 +207,10 @@ pub struct Session {
207207
pub asm_arch: Option<InlineAsmArch>,
208208

209209
/// Set of enabled features for the current target.
210-
pub target_features: FxHashSet<Symbol>,
210+
pub target_features: FxIndexSet<Symbol>,
211211

212212
/// Set of enabled features for the current target, including unstable ones.
213-
pub unstable_target_features: FxHashSet<Symbol>,
213+
pub unstable_target_features: FxIndexSet<Symbol>,
214214
}
215215

216216
pub struct PerfStats {
@@ -1484,8 +1484,8 @@ pub fn build_session(
14841484
ctfe_backtrace,
14851485
miri_unleashed_features: Lock::new(Default::default()),
14861486
asm_arch,
1487-
target_features: FxHashSet::default(),
1488-
unstable_target_features: FxHashSet::default(),
1487+
target_features: Default::default(),
1488+
unstable_target_features: Default::default(),
14891489
};
14901490

14911491
validate_commandline_args_with_session_available(&sess);

compiler/rustc_target/src/asm/aarch64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;
66
use std::fmt;
@@ -80,7 +80,7 @@ pub fn target_reserves_x18(target: &Target) -> bool {
8080
fn reserved_x18(
8181
_arch: InlineAsmArch,
8282
_reloc_model: RelocModel,
83-
_target_features: &FxHashSet<Symbol>,
83+
_target_features: &FxIndexSet<Symbol>,
8484
target: &Target,
8585
_is_clobber: bool,
8686
) -> Result<(), &'static str> {

compiler/rustc_target/src/asm/arm.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::{sym, Symbol};
66
use std::fmt;
@@ -64,14 +64,14 @@ impl ArmInlineAsmRegClass {
6464
}
6565

6666
// This uses the same logic as useR7AsFramePointer in LLVM
67-
fn frame_pointer_is_r7(target_features: &FxHashSet<Symbol>, target: &Target) -> bool {
67+
fn frame_pointer_is_r7(target_features: &FxIndexSet<Symbol>, target: &Target) -> bool {
6868
target.is_like_osx || (!target.is_like_windows && target_features.contains(&sym::thumb_mode))
6969
}
7070

7171
fn frame_pointer_r11(
7272
arch: InlineAsmArch,
7373
reloc_model: RelocModel,
74-
target_features: &FxHashSet<Symbol>,
74+
target_features: &FxIndexSet<Symbol>,
7575
target: &Target,
7676
is_clobber: bool,
7777
) -> Result<(), &'static str> {
@@ -87,7 +87,7 @@ fn frame_pointer_r11(
8787
fn frame_pointer_r7(
8888
_arch: InlineAsmArch,
8989
_reloc_model: RelocModel,
90-
target_features: &FxHashSet<Symbol>,
90+
target_features: &FxIndexSet<Symbol>,
9191
target: &Target,
9292
_is_clobber: bool,
9393
) -> Result<(), &'static str> {
@@ -101,7 +101,7 @@ fn frame_pointer_r7(
101101
fn not_thumb1(
102102
_arch: InlineAsmArch,
103103
_reloc_model: RelocModel,
104-
target_features: &FxHashSet<Symbol>,
104+
target_features: &FxIndexSet<Symbol>,
105105
_target: &Target,
106106
is_clobber: bool,
107107
) -> Result<(), &'static str> {
@@ -118,7 +118,7 @@ fn not_thumb1(
118118
fn reserved_r9(
119119
arch: InlineAsmArch,
120120
reloc_model: RelocModel,
121-
target_features: &FxHashSet<Symbol>,
121+
target_features: &FxIndexSet<Symbol>,
122122
target: &Target,
123123
is_clobber: bool,
124124
) -> Result<(), &'static str> {

compiler/rustc_target/src/asm/mod.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::spec::Target;
22
use crate::{abi::Size, spec::RelocModel};
3-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
3+
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;
66
use std::fmt;
@@ -37,13 +37,14 @@ macro_rules! def_reg_class {
3737

3838
pub(super) fn regclass_map() -> rustc_data_structures::fx::FxHashMap<
3939
super::InlineAsmRegClass,
40-
rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>,
40+
rustc_data_structures::fx::FxIndexSet<super::InlineAsmReg>,
4141
> {
42-
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
42+
use rustc_data_structures::fx::FxHashMap;
43+
use rustc_data_structures::fx::FxIndexSet;
4344
use super::InlineAsmRegClass;
4445
let mut map = FxHashMap::default();
4546
$(
46-
map.insert(InlineAsmRegClass::$arch($arch_regclass::$class), FxHashSet::default());
47+
map.insert(InlineAsmRegClass::$arch($arch_regclass::$class), FxIndexSet::default());
4748
)*
4849
map
4950
}
@@ -94,7 +95,7 @@ macro_rules! def_regs {
9495
pub fn validate(self,
9596
_arch: super::InlineAsmArch,
9697
_reloc_model: crate::spec::RelocModel,
97-
_target_features: &rustc_data_structures::fx::FxHashSet<Symbol>,
98+
_target_features: &rustc_data_structures::fx::FxIndexSet<Symbol>,
9899
_target: &crate::spec::Target,
99100
_is_clobber: bool,
100101
) -> Result<(), &'static str> {
@@ -118,11 +119,11 @@ macro_rules! def_regs {
118119
pub(super) fn fill_reg_map(
119120
_arch: super::InlineAsmArch,
120121
_reloc_model: crate::spec::RelocModel,
121-
_target_features: &rustc_data_structures::fx::FxHashSet<Symbol>,
122+
_target_features: &rustc_data_structures::fx::FxIndexSet<Symbol>,
122123
_target: &crate::spec::Target,
123124
_map: &mut rustc_data_structures::fx::FxHashMap<
124125
super::InlineAsmRegClass,
125-
rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>,
126+
rustc_data_structures::fx::FxIndexSet<super::InlineAsmReg>,
126127
>,
127128
) {
128129
#[allow(unused_imports)]
@@ -334,7 +335,7 @@ impl InlineAsmReg {
334335
self,
335336
arch: InlineAsmArch,
336337
reloc_model: RelocModel,
337-
target_features: &FxHashSet<Symbol>,
338+
target_features: &FxIndexSet<Symbol>,
338339
target: &Target,
339340
is_clobber: bool,
340341
) -> Result<(), &'static str> {
@@ -701,9 +702,9 @@ impl fmt::Display for InlineAsmType {
701702
pub fn allocatable_registers(
702703
arch: InlineAsmArch,
703704
reloc_model: RelocModel,
704-
target_features: &FxHashSet<Symbol>,
705+
target_features: &FxIndexSet<Symbol>,
705706
target: &crate::spec::Target,
706-
) -> FxHashMap<InlineAsmRegClass, FxHashSet<InlineAsmReg>> {
707+
) -> FxHashMap<InlineAsmRegClass, FxIndexSet<InlineAsmReg>> {
707708
match arch {
708709
InlineAsmArch::X86 | InlineAsmArch::X86_64 => {
709710
let mut map = x86::regclass_map();

compiler/rustc_target/src/asm/riscv.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::{sym, Symbol};
66
use std::fmt;
@@ -55,7 +55,7 @@ impl RiscVInlineAsmRegClass {
5555
fn not_e(
5656
_arch: InlineAsmArch,
5757
_reloc_model: RelocModel,
58-
target_features: &FxHashSet<Symbol>,
58+
target_features: &FxIndexSet<Symbol>,
5959
_target: &Target,
6060
_is_clobber: bool,
6161
) -> Result<(), &'static str> {

compiler/rustc_target/src/asm/x86.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InlineAsmArch, InlineAsmType};
22
use crate::spec::{RelocModel, Target};
3-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::FxIndexSet;
44
use rustc_macros::HashStable_Generic;
55
use rustc_span::Symbol;
66
use std::fmt;
@@ -147,7 +147,7 @@ impl X86InlineAsmRegClass {
147147
fn x86_64_only(
148148
arch: InlineAsmArch,
149149
_reloc_model: RelocModel,
150-
_target_features: &FxHashSet<Symbol>,
150+
_target_features: &FxIndexSet<Symbol>,
151151
_target: &Target,
152152
_is_clobber: bool,
153153
) -> Result<(), &'static str> {
@@ -161,7 +161,7 @@ fn x86_64_only(
161161
fn high_byte(
162162
arch: InlineAsmArch,
163163
_reloc_model: RelocModel,
164-
_target_features: &FxHashSet<Symbol>,
164+
_target_features: &FxIndexSet<Symbol>,
165165
_target: &Target,
166166
_is_clobber: bool,
167167
) -> Result<(), &'static str> {
@@ -174,7 +174,7 @@ fn high_byte(
174174
fn rbx_reserved(
175175
arch: InlineAsmArch,
176176
_reloc_model: RelocModel,
177-
_target_features: &FxHashSet<Symbol>,
177+
_target_features: &FxIndexSet<Symbol>,
178178
_target: &Target,
179179
_is_clobber: bool,
180180
) -> Result<(), &'static str> {
@@ -190,7 +190,7 @@ fn rbx_reserved(
190190
fn esi_reserved(
191191
arch: InlineAsmArch,
192192
_reloc_model: RelocModel,
193-
_target_features: &FxHashSet<Symbol>,
193+
_target_features: &FxIndexSet<Symbol>,
194194
_target: &Target,
195195
_is_clobber: bool,
196196
) -> Result<(), &'static str> {

0 commit comments

Comments
 (0)