@@ -5,16 +5,28 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
5
5
use rustc_middle:: bug;
6
6
use rustc_middle:: mir:: mono:: Visibility ;
7
7
use 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 } ;
9
9
use rustc_session:: config:: CrateType ;
10
10
use rustc_target:: spec:: RelocModel ;
11
11
use tracing:: debug;
12
12
13
+ use rustc_target:: callconv:: FnAbi ;
14
+
13
15
use crate :: context:: CodegenCx ;
14
16
use crate :: errors:: SymbolAlreadyDefined ;
15
17
use crate :: type_of:: LayoutLlvmExt ;
16
18
use crate :: { base, llvm} ;
17
19
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
+
18
30
impl < ' tcx > PreDefineCodegenMethods < ' tcx > for CodegenCx < ' _ , ' tcx > {
19
31
fn predefine_static (
20
32
& mut self ,
@@ -54,7 +66,14 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
54
66
assert ! ( !instance. args. has_infer( ) ) ;
55
67
56
68
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) ) ;
58
77
llvm:: set_linkage ( lldecl, base:: linkage_to_llvm ( linkage) ) ;
59
78
let attrs = self . tcx . codegen_instance_attrs ( instance. def ) ;
60
79
base:: set_link_section ( lldecl, & attrs) ;
0 commit comments