diff options
| author | bors <bors@rust-lang.org> | 2020-11-03 04:27:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-11-03 04:27:27 +0000 |
| commit | 7b5a9e9cd27f01311b5e19cefa1fb574d086d3da (patch) | |
| tree | 9230363beaf2afa06e6ee29a060339f2b8dd0d61 /compiler/rustc_codegen_llvm/src/attributes.rs | |
| parent | 4c0c5e099a3b1f1c6ad53115189c2710495588b3 (diff) | |
| parent | 81444b20495e5325a5122f0fba84224846a8dac8 (diff) | |
| download | rust-7b5a9e9cd27f01311b5e19cefa1fb574d086d3da.tar.gz rust-7b5a9e9cd27f01311b5e19cefa1fb574d086d3da.zip | |
Auto merge of #78448 - rylev:cache-foreign_modules, r=wesleywiser
foreign_modules query hash table lookups When compiling a large monolithic crate we're seeing huge times in the `foreign_modules` query due to repeated iteration over foreign modules (in order to find a module by its id). This implements hash table lookups so that which massively reduces time spent in that query in this particular case. We'll need to see if the overhead of creating the hash table has a negative impact on performance in more normal compilation scenarios. I'm working with `@wesleywiser` on this.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 2075c2e1911..d4872aedd70 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -378,8 +378,8 @@ pub fn provide_both(providers: &mut Providers) { .collect::<FxHashMap<_, _>>(); let mut ret = FxHashMap::default(); - for lib in tcx.foreign_modules(cnum).iter() { - let module = def_id_to_native_lib.get(&lib.def_id).and_then(|s| s.wasm_import_module); + for (def_id, lib) in tcx.foreign_modules(cnum).iter() { + let module = def_id_to_native_lib.get(&def_id).and_then(|s| s.wasm_import_module); let module = match module { Some(s) => s, None => continue, |
