@@ -97,6 +97,8 @@ cl::opt<bool> nonmarkedglobals_inactiveloads(
97
97
cl::opt<bool > EnzymeJuliaAddrLoad (
98
98
" enzyme-julia-addr-load" , cl::init(false ), cl::Hidden,
99
99
cl::desc(" Mark all loads resulting in an addr(13)* to be legal to redo" ));
100
+
101
+ void (*CustomErrorHandler)(const char *) = nullptr ;
100
102
}
101
103
102
104
struct CacheAnalysis {
@@ -1702,6 +1704,11 @@ const AugmentedReturn &EnzymeLogic::CreateAugmentedPrimal(
1702
1704
}
1703
1705
1704
1706
if (todiff->empty ()) {
1707
+ if (todiff->empty () && CustomErrorHandler) {
1708
+ std::string s =
1709
+ (" No augmented forward pass found for " + todiff->getName ()).str ();
1710
+ CustomErrorHandler (s.c_str ());
1711
+ }
1705
1712
llvm::errs () << " mod: " << *todiff->getParent () << " \n " ;
1706
1713
llvm::errs () << *todiff << " \n " ;
1707
1714
assert (0 && " attempting to differentiate function without definition" );
@@ -3195,6 +3202,10 @@ Function *EnzymeLogic::CreatePrimalAndGradient(
3195
3202
" return or non-constant" );
3196
3203
}
3197
3204
3205
+ if (key.todiff ->empty () && CustomErrorHandler) {
3206
+ std::string s = (" No derivative found for " + key.todiff ->getName ()).str ();
3207
+ CustomErrorHandler (s.c_str ());
3208
+ }
3198
3209
assert (!key.todiff ->empty ());
3199
3210
3200
3211
ReturnType retVal =
@@ -3922,6 +3933,11 @@ Function *EnzymeLogic::CreateForwardDiff(
3922
3933
todiff, &todiff->getEntryBlock (),
3923
3934
" Cannot use provided custom derivative pass" );
3924
3935
}
3936
+ if (todiff->empty () && CustomErrorHandler) {
3937
+ std::string s =
3938
+ (" No forward derivative found for " + todiff->getName ()).str ();
3939
+ CustomErrorHandler (s.c_str ());
3940
+ }
3925
3941
if (todiff->empty ())
3926
3942
llvm::errs () << *todiff << " \n " ;
3927
3943
assert (!todiff->empty ());
0 commit comments