aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/AliasAnalysis.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-08-16 14:42:10 +0200
committerNikita Popov <npopov@redhat.com>2023-08-16 14:43:01 +0200
commit3670ec2897c02e51a4c3e4b788c99ea70d6106ea (patch)
tree0197735eb70585d8c788ca6f3f47006ee792fd7e /llvm/lib/Analysis/AliasAnalysis.cpp
parent566065207ba33cdc6d76c2d0c9304182ab408f73 (diff)
downloadllvm-3670ec2897c02e51a4c3e4b788c99ea70d6106ea.zip
llvm-3670ec2897c02e51a4c3e4b788c99ea70d6106ea.tar.gz
llvm-3670ec2897c02e51a4c3e4b788c99ea70d6106ea.tar.bz2
[LICM][AA] Move isWritableObject() to AA (NFC)
Move this helper from LICM to AA, so it can be reused.
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/AliasAnalysis.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 7b2f91f..75fe68a8 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -908,3 +908,20 @@ bool llvm::isNotVisibleOnUnwind(const Value *Object,
return false;
}
+
+// We don't consider globals as writable: While the physical memory is writable,
+// we may not have provenance to perform the write.
+bool llvm::isWritableObject(const Value *Object) {
+ // TODO: Alloca might not be writable after its lifetime ends.
+ // See https://github.com/llvm/llvm-project/issues/51838.
+ if (isa<AllocaInst>(Object))
+ return true;
+
+ // TODO: Also handle sret.
+ if (auto *A = dyn_cast<Argument>(Object))
+ return A->hasByValAttr();
+
+ // TODO: Noalias shouldn't imply writability, this should check for an
+ // allocator function instead.
+ return isNoAliasCall(Object);
+}