Add an early return if handling multiple offload calls
This commit is contained in:
parent
43111396e3
commit
7eae36f017
1 changed files with 8 additions and 1 deletions
|
|
@ -68,8 +68,15 @@ impl<'ll> OffloadGlobals<'ll> {
|
|||
// which we copy from clang, is to just have those two calls once, in the global ctor/dtor section
|
||||
// of the final binary.
|
||||
pub(crate) fn register_offload<'ll>(cx: &CodegenCx<'ll, '_>) {
|
||||
// First we check quickly whether we already have done our setup, in which case we return early.
|
||||
// Shouldn't be needed for correctness.
|
||||
let register_lib_name = "__tgt_register_lib";
|
||||
if cx.get_function(register_lib_name).is_some() {
|
||||
return;
|
||||
}
|
||||
|
||||
let reg_lib_decl = cx.type_func(&[cx.type_ptr()], cx.type_void());
|
||||
let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", reg_lib_decl);
|
||||
let register_lib = declare_offload_fn(&cx, register_lib_name, reg_lib_decl);
|
||||
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", reg_lib_decl);
|
||||
|
||||
let ptr_null = cx.const_null(cx.type_ptr());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue