Auto merge of #69155 - chrissimpkins:llvm-globals, r=eddyb
Add support for LLVM globals corresponding to miri allocations should be named alloc123 Adds support for this request from @eddyb in #69134: > That is, if -Zfewer-names is false (usually only because of --emit=llvm-ir), we should use the same name for LLVM globals we generate out of miri allocs as #67133 does in MIR output (allocN). > >This way, we can easily see the mapping between MIR and LLVM IR (and it shouldn't be any costlier for regular compilation, which would continue to use unnamed globals). r? @eddyb cc @oli-obk
This commit is contained in:
commit
d6072319a9
3 changed files with 10 additions and 7 deletions
|
@ -259,11 +259,14 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
let base_addr = match alloc_kind {
|
let base_addr = match alloc_kind {
|
||||||
Some(GlobalAlloc::Memory(alloc)) => {
|
Some(GlobalAlloc::Memory(alloc)) => {
|
||||||
let init = const_alloc_to_llvm(self, alloc);
|
let init = const_alloc_to_llvm(self, alloc);
|
||||||
if alloc.mutability == Mutability::Mut {
|
let value = match alloc.mutability {
|
||||||
self.static_addr_of_mut(init, alloc.align, None)
|
Mutability::Mut => self.static_addr_of_mut(init, alloc.align, None),
|
||||||
} else {
|
_ => self.static_addr_of(init, alloc.align, None),
|
||||||
self.static_addr_of(init, alloc.align, None)
|
};
|
||||||
|
if !self.sess().fewer_names() {
|
||||||
|
llvm::set_value_name(value, format!("{:?}", ptr.alloc_id).as_bytes());
|
||||||
}
|
}
|
||||||
|
value
|
||||||
}
|
}
|
||||||
Some(GlobalAlloc::Function(fn_instance)) => self.get_fn_addr(fn_instance),
|
Some(GlobalAlloc::Function(fn_instance)) => self.get_fn_addr(fn_instance),
|
||||||
Some(GlobalAlloc::Static(def_id)) => {
|
Some(GlobalAlloc::Static(def_id)) => {
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
// CHECK: @STATIC = {{.*}}, align 4
|
// CHECK: @STATIC = {{.*}}, align 4
|
||||||
|
|
||||||
// This checks the constants from inline_enum_const
|
// This checks the constants from inline_enum_const
|
||||||
// CHECK: @{{[0-9]+}} = {{.*}}, align 2
|
// CHECK: @alloc5 = {{.*}}, align 2
|
||||||
|
|
||||||
// This checks the constants from {low,high}_align_const, they share the same
|
// This checks the constants from {low,high}_align_const, they share the same
|
||||||
// constant, but the alignment differs, so the higher one should be used
|
// constant, but the alignment differs, so the higher one should be used
|
||||||
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @2, i32 0, i32 0, i32 0), {{.*}},
|
// CHECK: [[LOW_HIGH:@[0-9]+]] = {{.*}} getelementptr inbounds (<{ [8 x i8] }>, <{ [8 x i8] }>* @alloc15, i32 0, i32 0, i32 0), {{.*}}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
// repr(i16) is required for the {low,high}_align_const test
|
// repr(i16) is required for the {low,high}_align_const test
|
||||||
|
|
|
@ -12,7 +12,7 @@ mod aux_mod;
|
||||||
include!("aux_mod.rs");
|
include!("aux_mod.rs");
|
||||||
|
|
||||||
// Here we check that the expansion of the file!() macro is mapped.
|
// Here we check that the expansion of the file!() macro is mapped.
|
||||||
// CHECK: @0 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }>, align 1
|
// CHECK: @alloc1 = private unnamed_addr constant <{ [34 x i8] }> <{ [34 x i8] c"/the/src/remap_path_prefix/main.rs" }>, align 1
|
||||||
pub static FILE_PATH: &'static str = file!();
|
pub static FILE_PATH: &'static str = file!();
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue