Skip to content

Commit 00d79e6

Browse files
authored
Add loose type fallback for atomics (rust-lang#723)
1 parent a16c616 commit 00d79e6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

enzyme/Enzyme/AdjointGenerator.h

+13-2
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,23 @@ class AdjointGenerator
835835
}
836836
}
837837
if (!gutils->isConstantInstruction(&I) || !gutils->isConstantValue(&I)) {
838+
if (looseTypeAnalysis) {
839+
auto &DL = gutils->newFunc->getParent()->getDataLayout();
840+
auto valType = I.getValOperand()->getType();
841+
auto storeSize = DL.getTypeSizeInBits(valType) / 8;
842+
auto fp = TR.firstPointer(storeSize, I.getPointerOperand(),
843+
/*errifnotfound*/ false,
844+
/*pointerIntSame*/ true);
845+
if (!fp.isKnown() && valType->isIntOrIntVectorTy()) {
846+
goto noerror;
847+
}
848+
}
838849
TR.dump();
839850
llvm::errs() << "oldFunc: " << *gutils->newFunc << "\n";
840851
llvm::errs() << "I: " << I << "\n";
852+
assert(0 && "Active atomic inst not handled");
841853
}
842-
assert(gutils->isConstantInstruction(&I));
843-
assert(gutils->isConstantValue(&I));
854+
noerror:;
844855

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

0 commit comments

Comments
 (0)