Skip to content

Commit

Permalink
fix noalias test, add addressof op
Browse files Browse the repository at this point in the history
  • Loading branch information
pengmai committed Feb 6, 2024
1 parent ada5515 commit 51e7a22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion enzyme/Enzyme/MLIR/Analysis/DataFlowActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "mlir/Analysis/DataFlow/DenseAnalysis.h"
#include "mlir/Analysis/DataFlow/SparseAnalysis.h"
#include "mlir/Analysis/DataFlowFramework.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"

// TODO: Don't depend on specific dialects
Expand Down Expand Up @@ -856,7 +857,7 @@ void printActivityAnalysisResults(const DataFlowSolver &solver,
});
};

if (isa_and_present<LLVM::PoisonOp, LLVM::ZeroOp>(
if (isa_and_present<LLVM::PoisonOp, LLVM::ZeroOp, LLVM::AddressOfOp>(
value.getDefiningOp())) {
// Alias classes aren't computed for poison ops, but they are
// definitionally constant.
Expand All @@ -867,6 +868,7 @@ void printActivityAnalysisResults(const DataFlowSolver &solver,
// TODO: We're seeing a case where we load from calloc which is
// defined to be zero.
errs() << "ac for " << value << " was undefined\n";
return true;
}
// If this triggers, investigate why the alias classes weren't computed.
// If they weren't computed legitimately, treat the value as
Expand Down
5 changes: 3 additions & 2 deletions enzyme/test/MLIR/AliasAnalysis/llvm_noalias.mlir
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// RUN: %eopt --test-print-alias-analysis --split-input-file %s 2>&1 | FileCheck %s

// The dataflow framework never sees what is stored into %x, but we know its load result does not alias
// with anything else in the function because it has `noalias`.
// with %x itself because of the `llvm.noalias`

// CHECK: "x" and "x_load": NoAlias
llvm.func @f(%x: !llvm.ptr {enzyme.tag = "x", llvm.noalias}) {
// CHECK: "y" and "x_load": MayAlias
llvm.func @f(%x: !llvm.ptr {enzyme.tag = "x", llvm.noalias}, %y: !llvm.ptr {enzyme.tag = "y"}) {
%x_load = llvm.load %x {tag = "x_load"} : !llvm.ptr -> !llvm.ptr
llvm.return
}

0 comments on commit 51e7a22

Please sign in to comment.