@@ -10,6 +10,7 @@ use crate::value::Value;
10
10
use rustc_ast:: Mutability ;
11
11
use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
12
12
use rustc_codegen_ssa:: traits:: * ;
13
+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
13
14
use rustc_hir:: def_id:: DefId ;
14
15
use rustc_middle:: bug;
15
16
use rustc_middle:: mir:: interpret:: { ConstAllocation , GlobalAlloc , Scalar } ;
@@ -252,8 +253,13 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
252
253
Mutability :: Mut => self . static_addr_of_mut ( init, alloc. align , None ) ,
253
254
_ => self . static_addr_of ( init, alloc. align , None ) ,
254
255
} ;
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 ( ) ) ;
257
263
}
258
264
( value, AddressSpace :: DATA )
259
265
}
0 commit comments