[llvm] 436fb27 - [BasicAA] Support loop phis in pointsToConstantMemory()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 17 03:40:51 PDT 2022
Author: Nikita Popov
Date: 2022-10-17T12:34:55+02:00
New Revision: 436fb271862d721f9292169a979791508fad96c7
URL: https://github.com/llvm/llvm-project/commit/436fb271862d721f9292169a979791508fad96c7
DIFF: https://github.com/llvm/llvm-project/commit/436fb271862d721f9292169a979791508fad96c7.diff
LOG: [BasicAA] Support loop phis in pointsToConstantMemory()
When looking for underlying objects, if we encounter one that we
have already seen, then we should skip it (as it has already been
checked) rather than bail out. In particular, this adds support
for the case where we have a loop use of a phi recurrence.
Added:
Modified:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Analysis/BasicAA/constant-memory.ll
llvm/test/Transforms/FunctionAttrs/readattrs.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 9ec34fa511460..7b6b6f739667a 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -695,7 +695,7 @@ bool BasicAAResult::pointsToConstantMemory(const MemoryLocation &Loc,
do {
const Value *V = getUnderlyingObject(Worklist.pop_back_val());
if (!Visited.insert(V).second)
- return AAResultBase::pointsToConstantMemory(Loc, AAQI, OrLocal);
+ continue;
// An alloca instruction defines local memory.
if (OrLocal && isa<AllocaInst>(V))
diff --git a/llvm/test/Analysis/BasicAA/constant-memory.ll b/llvm/test/Analysis/BasicAA/constant-memory.ll
index a14a1ea4fbbda..487d3c67a5266 100644
--- a/llvm/test/Analysis/BasicAA/constant-memory.ll
+++ b/llvm/test/Analysis/BasicAA/constant-memory.ll
@@ -13,9 +13,9 @@ define void @basic(ptr %p) {
ret void
}
-; FIXME: This should be at least only Ref.
+; FIXME: This could be NoModRef
; CHECK-LABEL: Function: recphi
-; Both ModRef: Ptr: i32* %p <-> call void @dummy()
+; CHECK: Just Ref: Ptr: i32* %p <-> call void @dummy()
define void @recphi() {
entry:
br label %loop
diff --git a/llvm/test/Transforms/FunctionAttrs/readattrs.ll b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
index ba968ec8e8b7d..f2ea7e4772bf5 100644
--- a/llvm/test/Transforms/FunctionAttrs/readattrs.ll
+++ b/llvm/test/Transforms/FunctionAttrs/readattrs.ll
@@ -289,7 +289,7 @@ define void @fptr_test2c(ptr %p, ptr %f) {
}
define void @alloca_recphi() {
-; CHECK: Function Attrs: nofree norecurse nosync nounwind
+; CHECK: Function Attrs: nofree norecurse nosync nounwind readnone
; CHECK-LABEL: define {{[^@]+}}@alloca_recphi
; CHECK-SAME: () #[[ATTR14:[0-9]+]] {
; CHECK-NEXT: entry:
More information about the llvm-commits
mailing list