Skip to content

Commit

Permalink
Add loose type fallback for atomics (rust-lang#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jun 29, 2022
1 parent a16c616 commit 00d79e6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions enzyme/Enzyme/AdjointGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,12 +835,23 @@ class AdjointGenerator
}
}
if (!gutils->isConstantInstruction(&I) || !gutils->isConstantValue(&I)) {
if (looseTypeAnalysis) {
auto &DL = gutils->newFunc->getParent()->getDataLayout();
auto valType = I.getValOperand()->getType();
auto storeSize = DL.getTypeSizeInBits(valType) / 8;
auto fp = TR.firstPointer(storeSize, I.getPointerOperand(),
/*errifnotfound*/ false,
/*pointerIntSame*/ true);
if (!fp.isKnown() && valType->isIntOrIntVectorTy()) {
goto noerror;
}
}
TR.dump();
llvm::errs() << "oldFunc: " << *gutils->newFunc << "\n";
llvm::errs() << "I: " << I << "\n";
assert(0 && "Active atomic inst not handled");
}
assert(gutils->isConstantInstruction(&I));
assert(gutils->isConstantValue(&I));
noerror:;

if (Mode == DerivativeMode::ReverseModeGradient) {
eraseIfUnused(I, /*erase*/ true, /*check*/ false);
Expand Down

0 comments on commit 00d79e6

Please sign in to comment.