Skip to content

Commit

Permalink
Fix handle out of sync error (rust-lang#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Sep 1, 2022
1 parent 01dc20b commit 185a576
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions enzyme/Enzyme/AdjointGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8527,9 +8527,10 @@ class AdjointGenerator

Value *invertedReturn = nullptr;
auto ifound = gutils->invertedPointers.find(orig);
PHINode *placeholder = nullptr;
if (ifound != gutils->invertedPointers.end()) {
if (shadowReturnUsed)
invertedReturn = cast<PHINode>(&*ifound->second);
invertedReturn = placeholder = cast<PHINode>(&*ifound->second);
}

Value *normalReturn = subretused ? newCall : nullptr;
Expand Down Expand Up @@ -8562,10 +8563,9 @@ class AdjointGenerator
tape);
}

if (ifound != gutils->invertedPointers.end()) {
auto placeholder = cast<PHINode>(&*ifound->second);
if (placeholder) {
if (!shadowReturnUsed) {
gutils->invertedPointers.erase(ifound);
gutils->invertedPointers.erase(orig);
gutils->erase(placeholder);
} else {
if (invertedReturn && invertedReturn != placeholder) {
Expand Down

0 comments on commit 185a576

Please sign in to comment.