@@ -716,6 +716,59 @@ function annotate!(mod::LLVM.Module)
716716 end
717717 end
718718
719+ for fname in (
720+ " julia.gc_alloc_obj" ,
721+ " jl_gc_alloc_typed" ,
722+ " ijl_gc_alloc_typed" ,
723+ " jl_alloc_genericmemory" ,
724+ " ijl_alloc_genericmemory" ,
725+ " jl_alloc_array_1d" ,
726+ " jl_alloc_array_2d" ,
727+ " jl_alloc_array_3d" ,
728+ " ijl_alloc_array_1d" ,
729+ " ijl_alloc_array_2d" ,
730+ " ijl_alloc_array_3d" ,
731+ " jl_alloc_genericmemory" ,
732+ " ijl_alloc_genericmemory" ,
733+ " ijl_new_array" ,
734+ " jl_new_array"
735+ )
736+ if haskey (funcs, fname)
737+ for fn in funcs[fname]
738+ push! (function_attributes (fn), LLVM. StringAttribute (" enzyme_ReadOnlyOrThrow" ))
739+ end
740+ end
741+ end
742+
743+ for fname in (
744+ " jl_box_float32" ,
745+ " jl_box_float64" ,
746+ " jl_box_int32" ,
747+ " jl_box_int64" ,
748+ " ijl_box_float32" ,
749+ " ijl_box_float64" ,
750+ " ijl_box_int32" ,
751+ " ijl_box_int64" ,
752+ " jl_array_copy" ,
753+ " ijl_array_copy" ,
754+ " jl_genericmemory_slice" ,
755+ " ijl_genericmemory_slice" ,
756+ " jl_genericmemory_copy_slice" ,
757+ " ijl_genericmemory_copy_slice" ,
758+ " jl_f_tuple" ,
759+ " ijl_f_tuple" ,
760+ " jl_new_structv" ,
761+ " ijl_new_structv" ,
762+ " jl_idtable_rehash" ,
763+ " ijl_idtable_rehash" ,
764+ )
765+ if haskey (funcs, fname)
766+ for fn in funcs[fname]
767+ push! (function_attributes (fn), LLVM. StringAttribute (" enzyme_LocalReadOnlyOrThrow" ))
768+ end
769+ end
770+ end
771+
719772 for fname in (
720773 " julia.gc_alloc_obj" ,
721774 " jl_gc_alloc_typed" ,
@@ -755,7 +808,6 @@ function annotate!(mod::LLVM.Module)
755808 )
756809 if haskey (funcs, fname)
757810 for fn in funcs[fname]
758- push! (function_attributes (fn), LLVM. StringAttribute (" enzyme_ReadOnlyOrThrow" ))
759811 push! (return_attributes (fn), LLVM. EnumAttribute (" noalias" , 0 ))
760812 push! (return_attributes (fn), LLVM. EnumAttribute (" nonnull" , 0 ))
761813 push! (function_attributes (fn), no_escaping_alloc)
0 commit comments