Skip to content

Commit 2fae608

Browse files
authored
Unrolled build for rust-lang#124178
Rollup merge of rust-lang#124178 - GuillaumeGomez:llvm-backend, r=oli-obk [cleanup] [llvm backend] Prevent creating the same `Instance::mono` multiple times Just a little thing I came across while going through the code. r? ```@oli-obk```
2 parents 25087e0 + d34be93 commit 2fae608

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ impl<'ll> CodegenCx<'ll, '_> {
260260

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

276-
let sym = self.tcx.symbol_name(Instance::mono(self.tcx, def_id)).name;
277+
let sym = self.tcx.symbol_name(instance).name;
277278
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
278279

279280
debug!(?sym, ?fn_attrs);
@@ -363,7 +364,7 @@ impl<'ll> CodegenCx<'ll, '_> {
363364
}
364365
}
365366

366-
self.instances.borrow_mut().insert(Instance::mono(self.tcx, def_id), g);
367+
self.instances.borrow_mut().insert(instance, g);
367368
g
368369
}
369370

0 commit comments

Comments
 (0)