Skip to content

Commit 8d66561

Browse files
committed
feat: readnone
1 parent d19ad9a commit 8d66561

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
@@ -452,18 +452,24 @@ struct MarkFunctionMemoryEffectsPass
452452
argEffectInfo.enzymexlaEffects);
453453

454454
if (isPointerType(funcOp.getArgument(i))) {
455-
if (argEffectInfo.readOnly) {
455+
llvm::dbgs() << "argEffectInfo.readOnly " << argEffectInfo.readOnly
456+
<< " argEffectInfo.writeOnly " << argEffectInfo.writeOnly
457+
<< " argEffectInfo.readNone " << argEffectInfo.readNone
458+
<< "\n";
459+
if (argEffectInfo.readOnly && !argEffectInfo.readNone) {
460+
assert(!argEffectInfo.writeOnly && "readOnly and writeOnly?");
456461
funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadonlyAttrName(),
457462
builder.getUnitAttr());
458463
}
459-
if (argEffectInfo.writeOnly) {
464+
if (argEffectInfo.writeOnly && !argEffectInfo.readNone) {
465+
assert(!argEffectInfo.readOnly && "writeOnly and readOnly?");
460466
funcOp.setArgAttr(i, LLVM::LLVMDialect::getWriteOnlyAttrName(),
461467
builder.getUnitAttr());
462468
}
463-
// if (argEffectInfo.readNone) {
464-
// funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadnoneAttrName(),
465-
// builder.getUnitAttr());
466-
// }
469+
if (argEffectInfo.readNone) {
470+
funcOp.setArgAttr(i, LLVM::LLVMDialect::getReadnoneAttrName(),
471+
builder.getUnitAttr());
472+
}
467473
if (!argEffects[i][3]) {
468474
funcOp.setArgAttr(i, LLVM::LLVMDialect::getNoFreeAttrName(),
469475
builder.getUnitAttr());

0 commit comments

Comments
 (0)