@@ -5,16 +5,28 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
55use rustc_middle:: bug;
66use rustc_middle:: mir:: mono:: Visibility ;
77use rustc_middle:: ty:: layout:: { FnAbiOf , HasTypingEnv , LayoutOf } ;
8- use rustc_middle:: ty:: { self , Instance , TypeVisitableExt } ;
8+ use rustc_middle:: ty:: { self , Ty , TyCtxt , Instance , TypeVisitableExt } ;
99use rustc_session:: config:: CrateType ;
1010use rustc_target:: spec:: RelocModel ;
1111use tracing:: debug;
1212
13+ use rustc_target:: callconv:: FnAbi ;
14+
1315use crate :: context:: CodegenCx ;
1416use crate :: errors:: SymbolAlreadyDefined ;
1517use crate :: type_of:: LayoutLlvmExt ;
1618use crate :: { base, llvm} ;
1719
20+ fn my_fn_abi < ' tcx > ( abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> FnAbi < ' tcx , Ty < ' tcx > > {
21+ let mut myABI = abi. clone ( ) ;
22+ dbg ! ( & myABI. args) ;
23+ let val = myABI. clone ( ) . args [ 0 ] . clone ( ) ;
24+ myABI. args = Box :: new ( [ val. clone ( ) , val. clone ( ) ] ) ;
25+ dbg ! ( & myABI. args) ;
26+ myABI
27+ }
28+
29+
1830impl < ' tcx > PreDefineCodegenMethods < ' tcx > for CodegenCx < ' _ , ' tcx > {
1931 fn predefine_static (
2032 & mut self ,
@@ -54,7 +66,14 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
5466 assert ! ( !instance. args. has_infer( ) ) ;
5567
5668 let fn_abi = self . fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
57- let lldecl = self . declare_fn ( symbol_name, fn_abi, Some ( instance) ) ;
69+ let fn_abi = if fn_abi. conv == rustc_abi:: CanonAbi :: GpuKernel {
70+ dbg ! ( "found gpu fn!" ) ;
71+ my_fn_abi ( fn_abi)
72+ } else {
73+ dbg ! ( "asdf!" ) ;
74+ fn_abi. clone ( )
75+ } ;
76+ let lldecl = self . declare_fn ( symbol_name, & fn_abi, Some ( instance) ) ;
5877 llvm:: set_linkage ( lldecl, base:: linkage_to_llvm ( linkage) ) ;
5978 let attrs = self . tcx . codegen_instance_attrs ( instance. def ) ;
6079 base:: set_link_section ( lldecl, & attrs) ;
0 commit comments