@@ -43,7 +43,7 @@ use crate::errors::{
4343use crate :: llvm:: diagnostic:: OptimizationDiagnosticKind :: * ;
4444use crate :: llvm:: { self , DiagnosticInfo } ;
4545use crate :: type_:: llvm_type_ptr;
46- use crate :: { LlvmCodegenBackend , ModuleLlvm , SimpleCx , base, common, llvm_util} ;
46+ use crate :: { LlvmCodegenBackend , ModuleLlvm , SimpleCx , attributes , base, common, llvm_util} ;
4747
4848pub ( crate ) fn llvm_err < ' a > ( dcx : DiagCtxtHandle < ' _ > , err : LlvmError < ' a > ) -> ! {
4949 match llvm:: last_error ( ) {
@@ -705,11 +705,12 @@ pub(crate) unsafe fn llvm_optimize(
705705 SimpleCx :: new ( module. module_llvm . llmod ( ) , module. module_llvm . llcx , cgcx. pointer_size ) ;
706706 // For now we only support up to 10 kernels named kernel_0 ... kernel_9, a follow-up PR is
707707 // introducing a proper offload intrinsic to solve this limitation.
708- for num in 0 .. 9 {
709- let name = format ! ( "kernel_{num}" ) ;
710- if let Some ( kernel ) = cx . get_function ( & name ) {
711- handle_offload ( & cx, kernel ) ;
708+ for func in cx . get_functions ( ) {
709+ let offload_kernel = "offload-kernel" ;
710+ if attributes :: has_string_attr ( func , offload_kernel ) {
711+ handle_offload ( & cx, func ) ;
712712 }
713+ attributes:: remove_string_attr_from_llfn ( func, offload_kernel) ;
713714 }
714715 }
715716
0 commit comments