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

Method static_addr_of

crates/rustc_codegen_nvvm/src/consts.rs:351–369  ·  view source on GitHub ↗
(&self, cv: &'ll Value, align: Align, kind: Option<&str>)

Source from the content-addressed store, hash-verified

349
350impl<'ll, 'tcx> StaticMethods for CodegenCx<'ll, 'tcx> {
351 fn static_addr_of(&self, cv: &'ll Value, align: Align, kind: Option<&str>) -> &'ll Value {
352 if let Some(&gv) = self.const_globals.borrow().get(&cv) {
353 unsafe {
354 // Upgrade the alignment in cases where the same constant is used with different
355 // alignment requirements
356 let llalign = align.bytes() as u32;
357 if llalign > llvm::LLVMGetAlignment(gv) {
358 llvm::LLVMSetAlignment(gv, llalign);
359 }
360 }
361 return gv;
362 }
363 let gv = self.static_addr_of_mut(cv, align, kind);
364 unsafe {
365 llvm::LLVMSetGlobalConstant(gv, True);
366 }
367 self.const_globals.borrow_mut().insert(cv, gv);
368 gv
369 }
370
371 fn codegen_static(&self, def_id: DefId, is_mutable: bool) {
372 unsafe {

Callers 2

scalar_to_backendMethod · 0.80
from_const_allocMethod · 0.80

Calls 4

borrowMethod · 0.80
static_addr_of_mutMethod · 0.80
borrow_mutMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected