@@ -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 ,
@@ -1368,18 +1369,27 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1368
1369
_src_align : Align ,
1369
1370
size : RValue < ' gcc > ,
1370
1371
flags : MemFlags ,
1372
+ tt : Option < FncTree > ,
1371
1373
) {
1372
1374
assert ! ( !flags. contains( MemFlags :: NONTEMPORAL ) , "non-temporal memcpy not supported" ) ;
1373
1375
let size = self . intcast ( size, self . type_size_t ( ) , false ) ;
1374
1376
let _is_volatile = flags. contains ( MemFlags :: VOLATILE ) ;
1375
1377
let dst = self . pointercast ( dst, self . type_i8p ( ) ) ;
1376
1378
let src = self . pointercast ( src, self . type_ptr_to ( self . type_void ( ) ) ) ;
1377
1379
let memcpy = self . context . get_builtin_function ( "memcpy" ) ;
1380
+
1381
+ // Create the memcpy call
1382
+ let call = self . context . new_call ( self . ___location , memcpy, & [ dst, src, size] ) ;
1383
+
1384
+ // TypeTree metadata for memcpy: when Enzyme encounters a memcpy during autodiff,
1385
+ if let Some ( _tt) = tt {
1386
+ // TODO(KMJ-007): implement TypeTree support for gcc backend
1387
+ // For now, we just ignore the TypeTree since gcc backend doesn't support autodiff yet
1388
+ // When autodiff support is added to gcc backend, this should attach TypeTree information
1389
+ // as function attributes similar to how LLVM backend does it.
1390
+ }
1378
1391
// TODO(antoyo): handle aligns and is_volatile.
1379
- self . block . add_eval (
1380
- self . ___location ,
1381
- self . context . new_call ( self . ___location , memcpy, & [ dst, src, size] ) ,
1382
- ) ;
1392
+ self . block . add_eval ( self . ___location , call) ;
1383
1393
}
1384
1394
1385
1395
fn memmove (
0 commit comments