Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir] move alias lattice update to relevant transfer function #1573

Merged
merged 6 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions enzyme/Enzyme/MLIR/Analysis/AliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,19 @@ void enzyme::PointsToPointerAnalysis::visitOperation(Operation *op,

SmallVector<MemoryEffects::EffectInstance> effects;
memory.getEffects(effects);

// If the operation allocates fresh memory and doesn't write into it, that
// memory is known not to point to any known alias class.
if (effects.size() == 1 &&
isa<MemoryEffects::Allocate>(effects.front().getEffect()) &&
effects.front().getValue()) {
const auto *destClasses =
getOrCreateFor<AliasClassLattice>(op, effects.front().getValue());
propagateIfChanged(
after, after->setPointingToEmpty(destClasses->getAliasClassesObject()));
return;
}

for (const auto &effect : effects) {
if (!isa<MemoryEffects::Write>(effect.getEffect()))
continue;
Expand Down Expand Up @@ -860,14 +873,6 @@ void enzyme::AliasAnalysis::transfer(
result->getPoint(),
originalClasses.getOriginalClass(result->getPoint(), debugLabel));
propagateIfChanged(result, result->join(fresh));

// The pointer to freshly allocated memory is known not to point to
// anything.
// TODO(zinenko): this is a bit strange to update _another_ lattice
// here.
auto *pointsTo = getOrCreate<PointsToSets>(op);
propagateIfChanged(pointsTo, pointsTo->setPointingToEmpty(
fresh.getAliasClassesObject()));
}
}
} else if (isa<MemoryEffects::Read>(effect.getEffect())) {
Expand Down
2 changes: 1 addition & 1 deletion enzyme/test/MLIR/AliasAnalysis/func_attributes.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func.func private @callee(%ptr : !llvm.ptr {llvm.readonly}) attributes {
}

// CHECK: points-to-pointer sets
// CHECK-NEXT: <empty>
// CHECK: <empty>
// CHECK-LABEL @call_other_none_arg_rw_readonly
func.func @call_other_none_arg_rw_readonly(%input: !llvm.ptr {enzyme.tag = "input"}) {
call @callee(%input) : (!llvm.ptr) -> ()
Expand Down
Loading