Skip to content

Commit 30334c9

Browse files
authored
Nicer ficticuous phi error (#1315)
1 parent 547ce88 commit 30334c9

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

enzyme/Enzyme/GradientUtils.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8038,12 +8038,22 @@ void GradientUtils::eraseFictiousPHIs() {
80388038
for (auto pair : phis) {
80398039
auto pp = pair.first;
80408040
if (pp->getNumUses() != 0) {
8041-
llvm::errs() << "mod:" << *oldFunc->getParent() << "\n";
8042-
llvm::errs() << "oldFunc:" << *oldFunc << "\n";
8043-
llvm::errs() << "newFunc:" << *newFunc << "\n";
8044-
llvm::errs() << " pp: " << *pp << " of " << *pair.second << "\n";
8041+
if (CustomErrorHandler) {
8042+
std::string str;
8043+
raw_string_ostream ss(str);
8044+
ss << "Illegal replace ficticious phi for: " << *pp << " of "
8045+
<< *pair.second;
8046+
CustomErrorHandler(str.c_str(), wrap(pair.second),
8047+
ErrorType::IllegalReplaceFicticiousPHIs, this,
8048+
wrap(pp), nullptr);
8049+
} else {
8050+
llvm::errs() << "mod:" << *oldFunc->getParent() << "\n";
8051+
llvm::errs() << "oldFunc:" << *oldFunc << "\n";
8052+
llvm::errs() << "newFunc:" << *newFunc << "\n";
8053+
llvm::errs() << " pp: " << *pp << " of " << *pair.second << "\n";
8054+
assert(pp->getNumUses() == 0);
8055+
}
80458056
}
8046-
assert(pp->getNumUses() == 0);
80478057
pp->replaceAllUsesWith(UndefValue::get(pp->getType()));
80488058
erase(pp);
80498059
}

enzyme/Enzyme/Utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ enum class ErrorType {
8383
InternalError = 5,
8484
TypeDepthExceeded = 6,
8585
MixedActivityError = 7,
86+
IllegalReplaceFicticiousPHIs = 8
8687
};
8788

8889
extern "C" {

0 commit comments

Comments
 (0)