@@ -27,6 +27,7 @@ use llvm::Linkage::*;
27
27
use crate :: back:: write:: {
28
28
self , CodegenDiagnosticsStage , DiagnosticHandlers , bitcode_section_name, save_temp_bitcode,
29
29
} ;
30
+ use crate :: builder:: SBuilder ;
30
31
use crate :: errors:: {
31
32
DynamicLinkingWithLTO , LlvmError , LtoBitcodeFromRlib , LtoDisallowed , LtoDylib , LtoProcMacro ,
32
33
} ;
@@ -630,7 +631,7 @@ fn enable_autodiff_settings(ad: &[config::AutoDiff]) {
630
631
llvm:: set_rust_rules ( true ) ;
631
632
}
632
633
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 ) {
634
635
let offload_entry_ty = cx. type_named_struct ( "struct.__tgt_offload_entry" ) ;
635
636
let kernel_arguments_ty = cx. type_named_struct ( "struct.__tgt_kernel_arguments" ) ;
636
637
let tptr = cx. type_ptr ( ) ;
@@ -706,7 +707,7 @@ fn gen_globals<'ll>(cx: &'ll SimpleCx<'_>) -> &'ll llvm::Type {
706
707
attributes:: apply_to_llfn ( bar, Function , & [ nounwind] ) ;
707
708
attributes:: apply_to_llfn ( baz, Function , & [ nounwind] ) ;
708
709
709
- offload_entry_ty
710
+ ( offload_entry_ty, at_one )
710
711
}
711
712
712
713
fn 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::
795
796
// 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
796
797
}
797
798
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) ;
799
801
// 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)
800
802
// 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)
801
803
// 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(
853
855
SimpleCx :: new ( module. module_llvm . llmod ( ) , & module. module_llvm . llcx , cgcx. pointer_size ) ;
854
856
if cx. get_function ( "gen_tgt_offload" ) . is_some ( ) {
855
857
856
- let offload_entry_ty = gen_globals ( & cx) ;
858
+ let ( offload_entry_ty, at_one ) = gen_globals ( & cx) ;
857
859
858
860
dbg ! ( "created struct" ) ;
859
861
for num in 0 ..9 {
@@ -863,7 +865,7 @@ pub(crate) fn run_pass_manager(
863
865
// TODO: replace num by proper fn name
864
866
gen_define_handling ( & cx, offload_entry_ty, num) ;
865
867
}
866
- gen_call_handling ( & cx) ;
868
+ gen_call_handling ( & cx, at_one ) ;
867
869
} else {
868
870
dbg ! ( "no marker found" ) ;
869
871
}
0 commit comments