Skip to content

Commit 829a3f0

Browse files
committed
Add an early return if handling multiple offload calls
1 parent 1b7de4b commit 829a3f0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ impl<'ll> OffloadGlobals<'ll> {
5757
}
5858

5959
pub(crate) fn register_offload<'ll>(cx: &CodegenCx<'ll, '_>) {
60+
// First we check quickly whether we already have done our setup,
61+
// in which case we can return early. Shouldn't affect correctness.
62+
if cx.get_function("__tgt_register_lib").is_some() {
63+
return;
64+
}
65+
6066
let reg_lib_decl = cx.type_func(&[cx.type_ptr()], cx.type_void());
6167
let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", reg_lib_decl);
6268
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", reg_lib_decl);

0 commit comments

Comments
 (0)