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 73e3c5c

Browse files
committedJan 1, 2024
Auto merge of rust-lang#119458 - cjgillot:anonymous-alloc, r=compiler-errors
Do not hash allocations to name them. Computing the stable hash behind an `Allocation` can be quite slow. The given name does not provide a lot of benefit: a hash is not meaningfully easier to understand than an arbitrary index.
2 parents e51e98d + 7177a04 commit 73e3c5c

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed
 

‎compiler/rustc_codegen_llvm/src/common.rs

-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::value::Value;
88

99
use rustc_ast::Mutability;
1010
use rustc_codegen_ssa::traits::*;
11-
use rustc_data_structures::stable_hasher::{Hash128, HashStable, StableHasher};
1211
use rustc_hir::def_id::DefId;
1312
use rustc_middle::bug;
1413
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
@@ -255,14 +254,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
255254
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
256255
_ => self.static_addr_of(init, alloc.align, None),
257256
};
258-
if !self.sess().fewer_names() && llvm::get_value_name(value).is_empty() {
259-
let hash = self.tcx.with_stable_hashing_context(|mut hcx| {
260-
let mut hasher = StableHasher::new();
261-
alloc.hash_stable(&mut hcx, &mut hasher);
262-
hasher.finish::<Hash128>()
263-
});
264-
llvm::set_value_name(value, format!("alloc_{hash:032x}").as_bytes());
265-
}
266257
(value, AddressSpace::DATA)
267258
}
268259
GlobalAlloc::Function(fn_instance) => (

‎tests/codegen/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
// CHECK: @STATIC = {{.*}}, align 4
1010

1111
// This checks the constants from inline_enum_const
12-
// CHECK: @alloc_af1f8e8e6f4b341431a1d405e652df2d = {{.*}}, align 2
12+
// CHECK: @0 = {{.*}}, align 2
1313

1414
// This checks the constants from {low,high}_align_const, they share the same
1515
// constant, but the alignment differs, so the higher one should be used
16-
// CHECK: [[LOW_HIGH:@alloc_[a-f0-9]+]] = {{.*}}, align 4
16+
// CHECK: @1 = {{.*}}, align 4
1717

1818
#[derive(Copy, Clone)]
1919
// repr(i16) is required for the {low,high}_align_const test
@@ -42,14 +42,14 @@ pub fn inline_enum_const() -> E<i8, i16> {
4242
#[no_mangle]
4343
pub fn low_align_const() -> E<i16, [i16; 3]> {
4444
// Check that low_align_const and high_align_const use the same constant
45-
// CHECK: memcpy.{{.+}}(ptr align 2 %_0, ptr align 2 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false)
45+
// CHECK: memcpy.{{.+}}(ptr align 2 %_0, ptr align 2 {{.*}}@1{{.*}}, i{{(32|64)}} 8, i1 false)
4646
*&E::A(0)
4747
}
4848

4949
// CHECK-LABEL: @high_align_const
5050
#[no_mangle]
5151
pub fn high_align_const() -> E<i16, i32> {
5252
// Check that low_align_const and high_align_const use the same constant
53-
// CHECK: memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}[[LOW_HIGH]]{{.*}}, i{{(32|64)}} 8, i1 false)
53+
// CHECK: memcpy.{{.+}}(ptr align 4 %_0, ptr align 4 {{.*}}@1{{.*}}, i{{(32|64)}} 8, i1 false)
5454
*&E::A(0)
5555
}

‎tests/codegen/remap_path_prefix/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod aux_mod;
1212
include!("aux_mod.rs");
1313

1414
// Here we check that the expansion of the file!() macro is mapped.
15-
// CHECK: @alloc_5761061597a97f66e13ef2ff92712c4b = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }>
15+
// CHECK: @0 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }>
1616
pub static FILE_PATH: &'static str = file!();
1717

1818
fn main() {

0 commit comments

Comments
 (0)
Please sign in to comment.