Skip to content

Commit

Permalink
Prevent creating the same Instance::mono multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 19, 2024
1 parent ad18fe0 commit 37b91ea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ impl<'ll> CodegenCx<'ll, '_> {

#[instrument(level = "debug", skip(self, llty))]
pub(crate) fn get_static_inner(&self, def_id: DefId, llty: &'ll Type) -> &'ll Value {
if let Some(&g) = self.instances.borrow().get(&Instance::mono(self.tcx, def_id)) {
let instance = Instance::mono(self.tcx, def_id);
if let Some(&g) = self.instances.borrow().get(&instance) {
trace!("used cached value");
return g;
}
Expand All @@ -259,7 +260,7 @@ impl<'ll> CodegenCx<'ll, '_> {
statics defined in the same CGU, but did not for `{def_id:?}`"
);

let sym = self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name;
let sym = self.tcx.symbol_name(instance).name;
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);

debug!(?sym, ?fn_attrs);
Expand Down

0 comments on commit 37b91ea

Please sign in to comment.