Skip to content

Commit

Permalink
Custom error for unknown shadow (rust-lang#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jan 29, 2022
1 parent 1b1cc19 commit 19ad3dd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions enzyme/Enzyme/GradientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ llvm::cl::opt<bool> EnzymeFreeInternalAllocations(
"enzyme-free-internal-allocations", cl::init(true), cl::Hidden,
cl::desc("Always free internal allocations (disable if allocation needs "
"access outside)"));
extern void (*CustomErrorHandler)(const char *);
}

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

if (CustomErrorHandler && isa<Constant>(oval)) {
std::string str;
raw_string_ostream ss(str);
ss << "cannot find shadow for " << *oval;
CustomErrorHandler(str.c_str());
}

llvm::errs() << *newFunc->getParent() << "\n";
llvm::errs() << "fn:" << *newFunc << "\noval=" << *oval
<< " icv=" << isConstantValue(oval) << "\n";
Expand Down

0 comments on commit 19ad3dd

Please sign in to comment.