@@ -27,6 +27,7 @@ use llvm::Linkage::*;
2727use crate :: back:: write:: {
2828 self , CodegenDiagnosticsStage , DiagnosticHandlers , bitcode_section_name, save_temp_bitcode,
2929} ;
30+ use crate :: builder:: SBuilder ;
3031use crate :: errors:: {
3132 DynamicLinkingWithLTO , LlvmError , LtoBitcodeFromRlib , LtoDisallowed , LtoDylib , LtoProcMacro ,
3233} ;
@@ -630,7 +631,7 @@ fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
630631 llvm:: set_rust_rules ( true ) ;
631632}
632633
633- fn gen_globals < ' ll > ( cx : & ' ll SimpleCx < ' _ > ) -> & ' ll llvm:: Type {
634+ fn gen_globals < ' ll > ( cx : & ' ll SimpleCx < ' _ > ) -> ( & ' ll llvm:: Type , & ' ll llvm :: Value ) {
634635 let offload_entry_ty = cx. type_named_struct ( "struct.__tgt_offload_entry" ) ;
635636 let kernel_arguments_ty = cx. type_named_struct ( "struct.__tgt_kernel_arguments" ) ;
636637 let tptr = cx. type_ptr ( ) ;
@@ -706,7 +707,7 @@ fn gen_globals<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll llvm::Type {
706707 attributes:: apply_to_llfn ( bar, Function , & [ nounwind] ) ;
707708 attributes:: apply_to_llfn ( baz, Function , & [ nounwind] ) ;
708709
709- offload_entry_ty
710+ ( offload_entry_ty, at_one )
710711}
711712
712713fn add_priv_unnamed_arr < ' ll > ( cx : & SimpleCx < ' ll > , name : & str , vals : & [ u64 ] ) -> & ' ll llvm:: Value {
@@ -795,7 +796,8 @@ fn gen_define_handling<'ll>(cx: &'ll SimpleCx<'_>, offload_entry_ty: &'ll llvm::
795796 // 5. @.offloading.entry.__omp_offloading_86fafab6_c40006a1__Z3fooPSt7complexIdES1_S0_m_l7 = weak constant %struct.__tgt_offload_entry { i64 0, i16 1, i16 1, i32 0, ptr @.__omp_offloading_86fafab6_c40006a1__Z3fooPSt7complexIdES1_S0_m_l7.region_id, ptr @.offloading.entry_name, i64 0, i64 0, ptr null }, section "omp_offloading_entries", align 1
796797}
797798
798- fn gen_call_handling < ' ll > ( cx : & ' ll SimpleCx < ' _ > ) {
799+ fn gen_call_handling < ' ll > ( cx : & ' ll SimpleCx < ' _ > , s_ident_t : & ' ll llvm:: Value ) {
800+ let builder = SBuilder :: build ( cx) ;
799801 // call void @__tgt_target_data_begin_mapper(ptr @1, i64 -1, i32 3, ptr %27, ptr %28, ptr %29, ptr @.offload_maptypes, ptr null, ptr null)
800802 // call void @__tgt_target_data_update_mapper(ptr @1, i64 -1, i32 2, ptr %46, ptr %47, ptr %48, ptr @.offload_maptypes.1, ptr null, ptr null)
801803 // call void @__tgt_target_data_end_mapper(ptr @1, i64 -1, i32 3, ptr %49, ptr %50, ptr %51, ptr @.offload_maptypes, ptr null, ptr null)
@@ -853,7 +855,7 @@ pub(crate) fn run_pass_manager(
853855 SimpleCx :: new ( module. module_llvm . llmod ( ) , & module. module_llvm . llcx , cgcx. pointer_size ) ;
854856 if cx. get_function ( "gen_tgt_offload" ) . is_some ( ) {
855857
856- let offload_entry_ty = gen_globals ( & cx) ;
858+ let ( offload_entry_ty, at_one ) = gen_globals ( & cx) ;
857859
858860 dbg ! ( "created struct" ) ;
859861 for num in 0 ..9 {
@@ -863,7 +865,7 @@ pub(crate) fn run_pass_manager(
863865 // TODO: replace num by proper fn name
864866 gen_define_handling ( & cx, offload_entry_ty, num) ;
865867 }
866- gen_call_handling ( & cx) ;
868+ gen_call_handling ( & cx, at_one ) ;
867869 } else {
868870 dbg ! ( "no marker found" ) ;
869871 }
0 commit comments