Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 37b91ea

Browse files
committedApr 19, 2024·
Prevent creating the same Instance::mono multiple times
1 parent ad18fe0 commit 37b91ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎compiler/rustc_codegen_llvm/src/consts.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ impl<'ll> CodegenCx<'ll, '_> {
246246

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

262-
let sym = self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name;
263+
let sym = self.tcx.symbol_name(instance).name;
263264
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
264265

265266
debug!(?sym, ?fn_attrs);

0 commit comments

Comments
 (0)
Please sign in to comment.