Skip to content

Commit 19ad3dd

Browse files
authored
Custom error for unknown shadow (rust-lang#456)
1 parent 1b1cc19 commit 19ad3dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

enzyme/Enzyme/GradientUtils.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ llvm::cl::opt<bool> EnzymeFreeInternalAllocations(
9494
"enzyme-free-internal-allocations", cl::init(true), cl::Hidden,
9595
cl::desc("Always free internal allocations (disable if allocation needs "
9696
"access outside)"));
97+
extern void (*CustomErrorHandler)(const char *);
9798
}
9899

99100
Value *GradientUtils::unwrapM(Value *const val, IRBuilder<> &BuilderM,
@@ -3417,6 +3418,13 @@ end:;
34173418
assert(BuilderM.GetInsertBlock()->getParent());
34183419
assert(oval);
34193420

3421+
if (CustomErrorHandler && isa<Constant>(oval)) {
3422+
std::string str;
3423+
raw_string_ostream ss(str);
3424+
ss << "cannot find shadow for " << *oval;
3425+
CustomErrorHandler(str.c_str());
3426+
}
3427+
34203428
llvm::errs() << *newFunc->getParent() << "\n";
34213429
llvm::errs() << "fn:" << *newFunc << "\noval=" << *oval
34223430
<< " icv=" << isConstantValue(oval) << "\n";

0 commit comments

Comments
 (0)