@@ -10,6 +10,7 @@ use gccjit::{
1010use rustc_abi as abi;
1111use rustc_abi:: { Align , HasDataLayout , Size , TargetDataLayout , WrappingRange } ;
1212use rustc_apfloat:: { Float , Round , Status , ieee} ;
13+ use rustc_ast:: expand:: typetree:: FncTree ;
1314use rustc_codegen_ssa:: MemFlags ;
1415use rustc_codegen_ssa:: common:: {
1516 AtomicRmwBinOp , IntPredicate , RealPredicate , SynchronizationScope , TypeKind ,
@@ -1364,18 +1365,27 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
13641365 _src_align : Align ,
13651366 size : RValue < ' gcc > ,
13661367 flags : MemFlags ,
1368+ tt : Option < FncTree > ,
13671369 ) {
13681370 assert ! ( !flags. contains( MemFlags :: NONTEMPORAL ) , "non-temporal memcpy not supported" ) ;
13691371 let size = self . intcast ( size, self . type_size_t ( ) , false ) ;
13701372 let _is_volatile = flags. contains ( MemFlags :: VOLATILE ) ;
13711373 let dst = self . pointercast ( dst, self . type_i8p ( ) ) ;
13721374 let src = self . pointercast ( src, self . type_ptr_to ( self . type_void ( ) ) ) ;
13731375 let memcpy = self . context . get_builtin_function ( "memcpy" ) ;
1376+
1377+ // Create the memcpy call
1378+ let call = self . context . new_call ( self . location , memcpy, & [ dst, src, size] ) ;
1379+
1380+ // TypeTree metadata for memcpy: when Enzyme encounters a memcpy during autodiff,
1381+ if let Some ( _tt) = tt {
1382+ // TODO(KMJ-007): implement TypeTree support for gcc backend
1383+ // For now, we just ignore the TypeTree since gcc backend doesn't support autodiff yet
1384+ // When autodiff support is added to gcc backend, this should attach TypeTree information
1385+ // as function attributes similar to how LLVM backend does it.
1386+ }
13741387 // TODO(antoyo): handle aligns and is_volatile.
1375- self . block . add_eval (
1376- self . location ,
1377- self . context . new_call ( self . location , memcpy, & [ dst, src, size] ) ,
1378- ) ;
1388+ self . block . add_eval ( self . location , call) ;
13791389 }
13801390
13811391 fn memmove (
0 commit comments