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

Method create_used_variable_impl

crates/rustc_codegen_nvvm/src/context.rs:181–196  ·  view source on GitHub ↗
(&self, name: *const c_char, values: &[&'ll Value])

Source from the content-addressed store, hash-verified

179 }
180
181 fn create_used_variable_impl(&self, name: *const c_char, values: &[&'ll Value]) {
182 let section = "llvm.metadata\0".as_ptr().cast();
183 let array = self.const_array(self.type_ptr_to(self.type_i8()), values);
184
185 unsafe {
186 trace!(
187 "Creating LLVM used variable with name `{}` and values:\n{:#?}",
188 CStr::from_ptr(name).to_str().unwrap(),
189 values
190 );
191 let g = llvm::LLVMAddGlobal(self.llmod, self.val_ty(array), name);
192 llvm::LLVMSetInitializer(g, array);
193 llvm::LLVMRustSetLinkage(g, llvm::Linkage::AppendingLinkage);
194 llvm::LLVMSetSection(g, section);
195 }
196 }
197}
198
199fn sanitize_global_ident(name: &str) -> String {

Callers 2

create_used_variableMethod · 0.80

Calls 7

LLVMRustSetLinkageFunction · 0.85
as_ptrMethod · 0.80
const_arrayMethod · 0.80
type_ptr_toMethod · 0.80
type_i8Method · 0.80
val_tyMethod · 0.80
castMethod · 0.45

Tested by

no test coverage detected