]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/common.rs
support LLVM globals corresponding to miri allocations
[rust.git] / src / librustc_codegen_llvm / common.rs
index 525b3af29f826d3a3b2c939eab9ec5ea32847c67..d2d8097233a4a9d0af588c902f8faa184e53e42d 100644 (file)
@@ -18,8 +18,8 @@
 
 use libc::{c_char, c_uint};
 
+use rustc_span::symbol::Symbol;
 use syntax::ast::Mutability;
-use syntax::symbol::Symbol;
 
 pub use crate::context::CodegenCx;
 
@@ -91,6 +91,7 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
     type Funclet = Funclet<'ll>;
 
     type DIScope = &'ll llvm::debuginfo::DIScope;
+    type DIVariable = &'ll llvm::debuginfo::DIVariable;
 }
 
 impl CodegenCx<'ll, 'tcx> {
@@ -258,11 +259,14 @@ fn scalar_to_backend(
                 let base_addr = match alloc_kind {
                     Some(GlobalAlloc::Memory(alloc)) => {
                         let init = const_alloc_to_llvm(self, alloc);
-                        if alloc.mutability == Mutability::Mut {
-                            self.static_addr_of_mut(init, alloc.align, None)
-                        } else {
-                            self.static_addr_of(init, alloc.align, None)
+                        let value = match alloc.mutability {
+                            Mutability::Mut => self.static_addr_of_mut(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::Static(def_id)) => {