diff options
author | Nikita Popov <npopov@redhat.com> | 2022-01-11 11:02:26 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-01-26 11:15:03 +0100 |
commit | 44cfc3a8169cfa3f6a2824ed9cee9ff269f5a8ea (patch) | |
tree | 92c69bb6188c818afdb8ae92ad818891a6bb2ad8 /llvm/lib/Analysis/AliasAnalysis.cpp | |
parent | 7c02776567cc9561e6691dc05235799da45e72d6 (diff) | |
download | llvm-44cfc3a8169cfa3f6a2824ed9cee9ff269f5a8ea.zip llvm-44cfc3a8169cfa3f6a2824ed9cee9ff269f5a8ea.tar.gz llvm-44cfc3a8169cfa3f6a2824ed9cee9ff269f5a8ea.tar.bz2 |
[LICM] Generalize unwinding check during scalar promotion
This extract a common isNotVisibleOnUnwind() helper into
AliasAnalysis, which handles allocas, byval arguments and noalias
calls. After D116998 this could also handle sret arguments. We
have similar logic in DSE and MemCpyOpt, which will be switched
to use this helper as well.
The noalias call case is a bit different from the others, because
it also requires that the object is not captured. The caller is
responsible for doing the appropriate check.
Differential Revision: https://reviews.llvm.org/D117000
Diffstat (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/AliasAnalysis.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 5658499..a8132e5 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -988,6 +988,29 @@ bool llvm::isIdentifiedFunctionLocal(const Value *V) { return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V); } +bool llvm::isNotVisibleOnUnwind(const Value *Object, + bool &RequiresNoCaptureBeforeUnwind) { + RequiresNoCaptureBeforeUnwind = false; + + // Alloca goes out of scope on unwind. + if (isa<AllocaInst>(Object)) + return true; + + // Byval goes out of scope on unwind. + if (auto *A = dyn_cast<Argument>(Object)) + return A->hasByValAttr(); + + // 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 + // memory either. + if (isNoAliasCall(Object)) { + RequiresNoCaptureBeforeUnwind = true; + return true; + } + + return false; +} + void llvm::getAAResultsAnalysisUsage(AnalysisUsage &AU) { // This function needs to be in sync with llvm::createLegacyPMAAResults -- if // more alias analyses are added to llvm::createLegacyPMAAResults, they need |