@@ -671,16 +671,15 @@ pub(crate) unsafe fn llvm_optimize(
671671 let first_arg_name = str:: from_utf8 ( & c_name) . unwrap ( ) ;
672672 // We might call llvm_optimize (and thus this code) multiple times on the same IR,
673673 // but we shouldn't add this helper ptr multiple times.
674+ // FIXME(offload): This could break if the user calls his first argument `dyn_ptr`.
674675 if first_arg_name == "dyn_ptr" {
675676 return ;
676677 }
677678
678679 // Create the new parameter list, with ptr as the first argument
679680 let mut new_param_types = Vec :: with_capacity ( old_param_count as usize + 1 ) ;
680681 new_param_types. push ( cx. type_ptr ( ) ) ;
681- for old_param in old_param_types {
682- new_param_types. push ( old_param) ;
683- }
682+ new_param_types. extend ( old_param_types) ;
684683
685684 // Create the new function type
686685 let ret_ty = unsafe { llvm:: LLVMGetReturnType ( old_fn_ty) } ;
@@ -714,10 +713,11 @@ pub(crate) unsafe fn llvm_optimize(
714713 llvm:: set_value_name ( new_fn, & name) ;
715714 }
716715
717- let consider_offload = config. offload . contains ( & config:: Offload :: Enable ) ;
718- if consider_offload && ( cgcx. target_arch == "amdgpu" || cgcx. target_arch == "nvptx64" ) {
716+ if cgcx. target_is_like_gpu && config. offload . contains ( & config:: Offload :: Enable ) {
719717 let cx =
720718 SimpleCx :: new ( module. module_llvm . llmod ( ) , module. module_llvm . llcx , cgcx. pointer_size ) ;
719+ // For now we only support up to 10 kernels named kernel_0 ... kernel_9, a follow-up PR is
720+ // introducing a proper offload intrinsic to solve this limitation.
721721 for num in 0 ..9 {
722722 let name = format ! ( "kernel_{num}" ) ;
723723 if let Some ( kernel) = cx. get_function ( & name) {
0 commit comments