diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp b/contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp index 7b2f91f5392a..da18279ae9b9 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/AliasAnalysis.cpp @@ -896,7 +896,7 @@ bool llvm::isNotVisibleOnUnwind(const Value *Object, // Byval goes out of scope on unwind. if (auto *A = dyn_cast<Argument>(Object)) - return A->hasByValAttr(); + return A->hasByValAttr() || A->hasAttribute(Attribute::DeadOnUnwind); // A noalias return is not accessible from any other code. If the pointer // does not escape prior to the unwind, then the caller cannot access the @@ -908,3 +908,28 @@ 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, + bool &ExplicitlyDereferenceableOnly) { + ExplicitlyDereferenceableOnly = false; + + // 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; + + if (auto *A = dyn_cast<Argument>(Object)) { + if (A->hasAttribute(Attribute::Writable)) { + ExplicitlyDereferenceableOnly = true; + return true; + } + + return A->hasByValAttr(); + } + + // TODO: Noalias shouldn't imply writability, this should check for an + // allocator function instead. + return isNoAliasCall(Object); +} |