Skip to content

Commit 9dd8dde

Browse files
committed
feat: readnone
1 parent 8f3c5fd commit 9dd8dde

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/enzyme_ad/jax/Passes/MarkFunctionMemoryEffectsPass.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,18 +449,24 @@ struct MarkFunctionMemoryEffectsPass
449449
argEffectInfo.enzymexlaEffects);
450450

451451
if (isPointerType(funcOp.getArgument(i))) {
452-
if (argEffectInfo.readOnly) {
452+
llvm::dbgs() << "argEffectInfo.readOnly " << argEffectInfo.readOnly
453+
<< " argEffectInfo.writeOnly " << argEffectInfo.writeOnly
454+
<< " argEffectInfo.readNone " << argEffectInfo.readNone
455+
<< "\n";
456+
if (argEffectInfo.readOnly && !argEffectInfo.readNone) {
457+
assert(!argEffectInfo.writeOnly && "readOnly and writeOnly?");
453458
funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadonlyAttrName(),
454459
builder.getUnitAttr());
455460
}
456-
if (argEffectInfo.writeOnly) {
461+
if (argEffectInfo.writeOnly && !argEffectInfo.readNone) {
462+
assert(!argEffectInfo.readOnly && "writeOnly and readOnly?");
457463
funcOp.setArgAttr(i, LLVM::LLVMDialect::getWriteOnlyAttrName(),
458464
builder.getUnitAttr());
459465
}
460-
// if (argEffectInfo.readNone) {
461-
// funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadnoneAttrName(),
462-
// builder.getUnitAttr());
463-
// }
466+
if (argEffectInfo.readNone) {
467+
funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadnoneAttrName(),
468+
builder.getUnitAttr());
469+
}
464470
if (!argEffects[i][3]) {
465471
funcOp.setArgAttr(i, LLVM::LLVMDialect::getNoFreeAttrName(),
466472
builder.getUnitAttr());

0 commit comments

Comments
 (0)