@@ -633,8 +633,12 @@ callback()
633633
634634println (" done (took " , time () - before_time, " seconds)" )
635635
636+ # ############################################################################################
636637# Test overdubbing of a call overload invoke
637638
639+ print (" running CtxCallOverload test..." )
640+ before_time = time ()
641+
638642using LinearAlgebra
639643
640644struct Dense{F,S,T}
@@ -663,3 +667,38 @@ let d = Dense(3,3)
663667 data = rand (3 )
664668 Cassette. overdub (CtxCallOverload (), d, data)
665669end
670+
671+ println (" done (took " , time () - before_time, " seconds)" )
672+
673+ # ############################################################################################
674+
675+ print (" running LLVMCallCtx test..." )
676+ before_time = time ()
677+ using Cassette
678+ Cassette. @context LLVMCallCtx
679+
680+ # This overdub does nothing
681+ @noinline function Cassette. overdub (ctx:: LLVMCallCtx , f, args... )
682+ if Cassette. canrecurse (ctx, f, args... )
683+ Cassette. recurse (ctx, f, args... )
684+ else
685+ Cassette. fallback (ctx, f, args... )
686+ end
687+ end
688+
689+ import Core. Intrinsics
690+ function llvm_sin (x:: Float64 )
691+ # Needs fix for Core.Intrinsics.llvmcall
692+ Intrinsics. llvmcall (
693+ (
694+ """ declare double @llvm.sin.f64(double)""" ,
695+ """ %2 = call double @llvm.sin.f64(double %0)
696+ ret double %2"""
697+ ),
698+ Float64, Tuple{Float64}, x
699+ )
700+ end
701+
702+ Cassette. @overdub LLVMCallCtx () llvm_sin (4.0 )
703+
704+ println (" done (took " , time () - before_time, " seconds)" )
0 commit comments