mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 03:38:29 +00:00
Name LLVM anonymous constants by a hash of their contents
This commit is contained in:
parent
6ffabf3c8f
commit
a913a2bca9
@ -10,6 +10,7 @@ use crate::value::Value;
|
|||||||
use rustc_ast::Mutability;
|
use rustc_ast::Mutability;
|
||||||
use rustc_codegen_ssa::mir::place::PlaceRef;
|
use rustc_codegen_ssa::mir::place::PlaceRef;
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
|
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
|
||||||
@ -252,8 +253,13 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
|
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
|
||||||
_ => self.static_addr_of(init, alloc.align, None),
|
_ => self.static_addr_of(init, alloc.align, None),
|
||||||
};
|
};
|
||||||
if !self.sess().fewer_names() {
|
if !self.sess().fewer_names() && llvm::get_value_name(value).is_empty() {
|
||||||
llvm::set_value_name(value, format!("{:?}", alloc_id).as_bytes());
|
let hash = self.tcx.with_stable_hashing_context(|mut hcx| {
|
||||||
|
let mut hasher = StableHasher::new();
|
||||||
|
alloc.hash_stable(&mut hcx, &mut hasher);
|
||||||
|
hasher.finish::<u128>()
|
||||||
|
});
|
||||||
|
llvm::set_value_name(value, format!("alloc_{hash:032x}").as_bytes());
|
||||||
}
|
}
|
||||||
(value, AddressSpace::DATA)
|
(value, AddressSpace::DATA)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user