MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / get_fn_ext

Method get_fn_ext

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs:39–55  ·  view source on GitHub ↗

Returns a function if it already exists, or declares a header if it doesn't.

(&self, instance: Instance<'tcx>)

Source from the content-addressed store, hash-verified

37impl<'tcx> CodegenCx<'tcx> {
38 /// Returns a function if it already exists, or declares a header if it doesn't.
39 pub fn get_fn_ext(&self, instance: Instance<'tcx>) -> SpirvValue {
40 assert!(!instance.substs.has_infer());
41 assert!(!instance.substs.has_escaping_bound_vars());
42
43 if let Some(&func) = self.instances.borrow().get(&instance) {
44 return func;
45 }
46
47 // Because we've already declared everything with predefine_fn, if we hit this branch, we're guaranteed to be
48 // importing this function from elsewhere. So, slap an extern on it.
49 let linkage = Some(LinkageType::Import);
50 let llfn = self.declare_fn_ext(instance, linkage);
51
52 self.instances.borrow_mut().insert(instance, llfn);
53
54 llfn
55 }
56
57 // The call graph of how this is reachable is a little tangled, so:
58 // MiscMethods::get_fn -> get_fn_ext -> declare_fn_ext

Callers 1

get_fnMethod · 0.80

Calls 3

declare_fn_extMethod · 0.80
insertMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected