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

Function LLVMRustGetOrInsertFunction

crates/rustc_codegen_nvvm/src/llvm.rs:566–575  ·  view source on GitHub ↗

These functions are kind of a hack for the future. They wrap LLVM 7 rust shim functions and turn them into the API that the llvm 12 shim has. This way, if nvidia ever updates their dinosaur llvm version, switching for us should be extremely easy. `Name` is assumed to be a utf8 string

(
    M: &'a Module,
    Name: *const c_char,
    NameLen: usize,
    FunctionTy: &'a Type,
)

Source from the content-addressed store, hash-verified

564// dinosaur llvm version, switching for us should be extremely easy. `Name` is assumed to be
565// a utf8 string
566pub(crate) unsafe fn LLVMRustGetOrInsertFunction<'a>(
567 M: &'a Module,
568 Name: *const c_char,
569 NameLen: usize,
570 FunctionTy: &'a Type,
571) -> &'a Value {
572 let str = std::str::from_utf8_unchecked(std::slice::from_raw_parts(Name.cast(), NameLen));
573 let cstring = CString::new(str).expect("str with nul");
574 __LLVMRustGetOrInsertFunction(M, cstring.as_ptr(), FunctionTy)
575}
576
577pub(crate) unsafe fn LLVMRustBuildCall<'a>(
578 B: &Builder<'a>,

Callers 3

codegenFunction · 0.70
newMethod · 0.70
declare_fnMethod · 0.70

Calls 5

newFunction · 0.85
as_ptrMethod · 0.80
from_raw_partsFunction · 0.50
castMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected