@@ -10,6 +10,7 @@ use crate::value::Value;
1010use rustc_ast:: Mutability ;
1111use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
1212use rustc_codegen_ssa:: traits:: * ;
13+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1314use rustc_hir:: def_id:: DefId ;
1415use rustc_middle:: bug;
1516use rustc_middle:: mir:: interpret:: { ConstAllocation , GlobalAlloc , Scalar } ;
@@ -252,8 +253,13 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
252253 Mutability :: Mut => self . static_addr_of_mut ( init, alloc. align , None ) ,
253254 _ => self . static_addr_of ( init, alloc. align , None ) ,
254255 } ;
255- if !self . sess ( ) . fewer_names ( ) {
256- llvm:: set_value_name ( value, format ! ( "{:?}" , alloc_id) . as_bytes ( ) ) ;
256+ if !self . sess ( ) . fewer_names ( ) && llvm:: get_value_name ( value) . is_empty ( ) {
257+ let hash = self . tcx . with_stable_hashing_context ( |mut hcx| {
258+ let mut hasher = StableHasher :: new ( ) ;
259+ alloc. hash_stable ( & mut hcx, & mut hasher) ;
260+ hasher. finish :: < u128 > ( )
261+ } ) ;
262+ llvm:: set_value_name ( value, format ! ( "alloc_{hash:032x}" ) . as_bytes ( ) ) ;
257263 }
258264 ( value, AddressSpace :: DATA )
259265 }
0 commit comments