MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / predefine_static

Method predefine_static

crates/rustc_codegen_nvvm/src/mono_item.rs:26–54  ·  view source on GitHub ↗
(
        &self,
        def_id: DefId,
        linkage: Linkage,
        visibility: Visibility,
        symbol_name: &str,
    )

Source from the content-addressed store, hash-verified

24
25impl<'ll, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
26 fn predefine_static(
27 &self,
28 def_id: DefId,
29 linkage: Linkage,
30 visibility: Visibility,
31 symbol_name: &str,
32 ) {
33 trace!("Predefining static with name `{}`", symbol_name);
34 let instance = Instance::mono(self.tcx, def_id);
35 let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all());
36 let llty = self.layout_of(ty).llvm_type(self);
37 let addrspace = self.static_addrspace(instance);
38
39 let g = self
40 .define_global(symbol_name, llty, addrspace)
41 .unwrap_or_else(|| {
42 self.sess().span_fatal(
43 self.tcx.def_span(def_id),
44 &format!("symbol `{}` is already defined", symbol_name),
45 )
46 });
47
48 unsafe {
49 llvm::LLVMRustSetLinkage(g, linkage_to_llvm(linkage));
50 llvm::LLVMRustSetVisibility(g, visibility_to_llvm(visibility));
51 }
52
53 self.instances.borrow_mut().insert(instance, g);
54 }
55
56 fn predefine_fn(
57 &self,

Callers

nothing calls this directly

Calls 9

LLVMRustSetLinkageFunction · 0.85
linkage_to_llvmFunction · 0.85
LLVMRustSetVisibilityFunction · 0.85
visibility_to_llvmFunction · 0.85
static_addrspaceMethod · 0.80
define_globalMethod · 0.80
sessMethod · 0.80
borrow_mutMethod · 0.80
llvm_typeMethod · 0.45

Tested by

no test coverage detected