@@ -10,6 +10,7 @@ use gccjit::{
10
10
use rustc_abi as abi;
11
11
use rustc_abi:: { Align , HasDataLayout , Size , TargetDataLayout , WrappingRange } ;
12
12
use rustc_apfloat:: { Float , Round , Status , ieee} ;
13
+ use rustc_ast:: expand:: typetree:: FncTree ;
13
14
use rustc_codegen_ssa:: MemFlags ;
14
15
use rustc_codegen_ssa:: common:: {
15
16
AtomicRmwBinOp , IntPredicate , RealPredicate , SynchronizationScope , TypeKind ,
@@ -1383,18 +1384,27 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1383
1384
_src_align : Align ,
1384
1385
size : RValue < ' gcc > ,
1385
1386
flags : MemFlags ,
1387
+ tt : Option < FncTree > ,
1386
1388
) {
1387
1389
assert ! ( !flags. contains( MemFlags :: NONTEMPORAL ) , "non-temporal memcpy not supported" ) ;
1388
1390
let size = self . intcast ( size, self . type_size_t ( ) , false ) ;
1389
1391
let _is_volatile = flags. contains ( MemFlags :: VOLATILE ) ;
1390
1392
let dst = self . pointercast ( dst, self . type_i8p ( ) ) ;
1391
1393
let src = self . pointercast ( src, self . type_ptr_to ( self . type_void ( ) ) ) ;
1392
1394
let memcpy = self . context . get_builtin_function ( "memcpy" ) ;
1395
+
1396
+ // Create the memcpy call
1397
+ let call = self . context . new_call ( self . location , memcpy, & [ dst, src, size] ) ;
1398
+
1399
+ // TypeTree metadata for memcpy: when Enzyme encounters a memcpy during autodiff,
1400
+ if let Some ( _tt) = tt {
1401
+ // TODO(KMJ-007): implement TypeTree support for gcc backend
1402
+ // For now, we just ignore the TypeTree since gcc backend doesn't support autodiff yet
1403
+ // When autodiff support is added to gcc backend, this should attach TypeTree information
1404
+ // as function attributes similar to how LLVM backend does it.
1405
+ }
1393
1406
// TODO(antoyo): handle aligns and is_volatile.
1394
- self . block . add_eval (
1395
- self . location ,
1396
- self . context . new_call ( self . location , memcpy, & [ dst, src, size] ) ,
1397
- ) ;
1407
+ self . block . add_eval ( self . location , call) ;
1398
1408
}
1399
1409
1400
1410
fn memmove (
0 commit comments