]> git.lizzy.rs Git - rust.git/blobdiff - src/mono_item.rs
debuginfo: Refactor debuginfo generation for types -- Rename DebugInfoMethods::create...
[rust.git] / src / mono_item.rs
index c261efbbc559ffc8628d6f9d18338e9802b07c67..e21d40b6c37e37f67bf4644b78aefcd7c13fe2cd 100644 (file)
@@ -2,10 +2,8 @@
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::mir::mono::{Linkage, Visibility};
 use rustc_middle::ty::{self, Instance, TypeFoldable};
-use rustc_middle::ty::layout::FnAbiExt;
+use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
 use rustc_span::def_id::DefId;
-use rustc_target::abi::LayoutOf;
-use rustc_target::abi::call::FnAbi;
 
 use crate::base;
 use crate::context::CodegenCx;
@@ -19,41 +17,22 @@ fn predefine_static(&self, def_id: DefId, _linkage: Linkage, _visibility: Visibi
         let gcc_type = self.layout_of(ty).gcc_type(self, true);
 
         let is_tls = attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);
-        let global = self.define_global(symbol_name, gcc_type, is_tls, attrs.link_section).unwrap_or_else(|| {
-            self.sess().span_fatal(
-                self.tcx.def_span(def_id),
-                &format!("symbol `{}` is already defined", symbol_name),
-            )
-        });
-
-        // TODO
-        /*unsafe {
-            llvm::LLVMRustSetLinkage(global, base::linkage_to_llvm(linkage));
-            llvm::LLVMRustSetVisibility(global, base::visibility_to_llvm(visibility));
-        }*/
+        let global = self.define_global(symbol_name, gcc_type, is_tls, attrs.link_section);
 
+        // TODO(antoyo): set linkage and visibility.
         self.instances.borrow_mut().insert(instance, global);
     }
 
     fn predefine_fn(&self, instance: Instance<'tcx>, linkage: Linkage, _visibility: Visibility, symbol_name: &str) {
-        assert!(!instance.substs.needs_infer() && !instance.substs.has_param_types_or_consts());
+        assert!(!instance.substs.needs_infer());
 
-        let fn_abi = FnAbi::of_instance(self, instance, &[]);
+        let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
         self.linkage.set(base::linkage_to_gcc(linkage));
         let _decl = self.declare_fn(symbol_name, &fn_abi);
         //let attrs = self.tcx.codegen_fn_attrs(instance.def_id());
 
-        // TODO: call set_link_section() to allow initializing argc/argv.
-        //base::set_link_section(decl, &attrs);
-        /*if linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR {
-            llvm::SetUniqueComdat(self.llmod, decl);
-        }*/
-
-        //debug!("predefine_fn: instance = {:?}", instance);
-
-        // TODO: use inline attribute from there in linkage.set() above:
-        //attributes::from_fn_attrs(self, decl, instance);
-
-        //self.instances.borrow_mut().insert(instance, decl);
+        // TODO(antoyo): call set_link_section() to allow initializing argc/argv.
+        // TODO(antoyo): set unique comdat.
+        // TODO(antoyo): use inline attribute from there in linkage.set() above.
     }
 }