Skip to content

Commit

Permalink
[mlir] better handling of function result attributes
Browse files Browse the repository at this point in the history
Specifically, handle the siutation where some alias classes are
associateded with pointer operands that cannot be written into. In such
a case, even if the results of the function may alias the operands, the
alias classes of the operands are known not to point to anything that
the function could have written.

Additionally, don't include results marked as `noalias` into the common
alias class of function results.
  • Loading branch information
ftynse authored and pengmai committed Feb 27, 2024
1 parent 76f18ce commit 2d07aad
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
6 changes: 0 additions & 6 deletions enzyme/Enzyme/MLIR/Analysis/AliasAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,6 @@ class AliasClassLattice : public dataflow::AbstractSparseLattice {
const AliasClassSet &getAliasClassesObject() const { return aliasClasses; }

private:
struct UndefinedState {};

AliasClassLattice(Value value, AliasClassSet &&classes)
: dataflow::AbstractSparseLattice(value),
aliasClasses(std::move(classes)) {}

AliasClassSet aliasClasses;
};

Expand Down
13 changes: 0 additions & 13 deletions enzyme/test/MLIR/AliasAnalysis/func_attributes.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ func.func private @callee() -> (!llvm.ptr {llvm.noalias}) attributes {
}

// CHECK: points-to-pointer sets
<<<<<<< HEAD
// CHECK-NEXT: distinct[{{.+}}]<"func-return0"> points to {<unknown>}
=======
// CHECK-NEXT: distinct[{{.+}}]<"func-return"> points to {<unknown>}
>>>>>>> e5d11b44 ([mlir] add a proper "undefined" state to pointer analyses)
func.func @func_return_noalias() -> !llvm.ptr {
%0 = call @callee() {tag = "func-return"} : () -> !llvm.ptr
return %0 : !llvm.ptr
Expand All @@ -239,11 +235,7 @@ func.func @func_return_noalias() -> !llvm.ptr {
// CHECK: tag "func-return" Unknown AC
// CHECK: "func-return" and "func-return": MayAlias
// CHECK: points-to-pointer sets
<<<<<<< HEAD
// CHECK-NEXT: distinct[{{.*}}]<"func-return0"> points to {<unknown>}
=======
// CHECK-NEXT: distinct[{{.*}}]<"func-return"> points to {<unknown>}
>>>>>>> e5d11b44 ([mlir] add a proper "undefined" state to pointer analyses)
func.func private @callee() -> (!llvm.ptr {llvm.noalias}, !llvm.ptr) attributes {
memory = #llvm.memory_effects<other = read,
argMem = readwrite,
Expand All @@ -265,13 +257,8 @@ func.func private @callee() -> (!llvm.ptr {llvm.noalias}) attributes {

// CHECK: "func-1-return" and "func-2-return": NoAlias
// CHECK: points-to-pointer sets
<<<<<<< HEAD
// CHECK-DAG: distinct[{{.+}}]<"func-1-return0"> points to {<unknown>}
// CHECK-DAG: distinct[{{.+}}]<"func-2-return0"> points to {<unknown>}
=======
// CHECK-DAG: distinct[{{.+}}]<"func-return-1"> points to {<unknown>}
// CHECK-DAG: distinct[{{.+}}]<"func-return-2"> points to {<unknown>}
>>>>>>> e5d11b44 ([mlir] add a proper "undefined" state to pointer analyses)
func.func @caller() -> !llvm.ptr {
%0 = call @callee() {tag = "func-1-return"} : () -> !llvm.ptr
%1 = call @callee() {tag = "func-2-return"} : () -> !llvm.ptr
Expand Down

0 comments on commit 2d07aad

Please sign in to comment.