[llvm-branch-commits] [llvm] 82bd64f - [AA] byval argument is identified function local

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 21 11:23:13 PST 2020


Author: Nikita Popov
Date: 2020-12-21T20:18:23+01:00
New Revision: 82bd64fff63272c92b91a951ffde678fb9af4899

URL: https://github.com/llvm/llvm-project/commit/82bd64fff63272c92b91a951ffde678fb9af4899
DIFF: https://github.com/llvm/llvm-project/commit/82bd64fff63272c92b91a951ffde678fb9af4899.diff

LOG: [AA] byval argument is identified function local

byval arguments should mostly get the same treatment as noalias
arguments in alias analysis. This was not the case for the
isIdentifiedFunctionLocal() function.

Marking byval arguments as identified function local means that
they cannot alias with other arguments, which I believe is correct.

Differential Revision: https://reviews.llvm.org/D93602

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/AliasAnalysis.h
    llvm/lib/Analysis/AliasAnalysis.cpp
    llvm/test/Analysis/BasicAA/noalias-param.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h
index b84febaeeeaa..98a2a7fb075a 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -1097,9 +1097,6 @@ template <typename DerivedT> class AAResultBase {
 /// Return true if this pointer is returned by a noalias function.
 bool isNoAliasCall(const Value *V);
 
-/// Return true if this is an argument with the noalias attribute.
-bool isNoAliasArgument(const Value *V);
-
 /// Return true if this pointer refers to a distinct and identifiable object.
 /// This returns true for:
 ///    Global Variables and Functions (but not Global Aliases)

diff  --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 7d4969cc24c4..f5b62ef06a23 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -943,9 +943,9 @@ bool llvm::isNoAliasCall(const Value *V) {
   return false;
 }
 
-bool llvm::isNoAliasArgument(const Value *V) {
+static bool isNoAliasOrByValArgument(const Value *V) {
   if (const Argument *A = dyn_cast<Argument>(V))
-    return A->hasNoAliasAttr();
+    return A->hasNoAliasAttr() || A->hasByValAttr();
   return false;
 }
 
@@ -956,13 +956,13 @@ bool llvm::isIdentifiedObject(const Value *V) {
     return true;
   if (isNoAliasCall(V))
     return true;
-  if (const Argument *A = dyn_cast<Argument>(V))
-    return A->hasNoAliasAttr() || A->hasByValAttr();
+  if (isNoAliasOrByValArgument(V))
+    return true;
   return false;
 }
 
 bool llvm::isIdentifiedFunctionLocal(const Value *V) {
-  return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
+  return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasOrByValArgument(V);
 }
 
 void llvm::getAAResultsAnalysisUsage(AnalysisUsage &AU) {

diff  --git a/llvm/test/Analysis/BasicAA/noalias-param.ll b/llvm/test/Analysis/BasicAA/noalias-param.ll
index aab55595da2a..81c89feaabb4 100644
--- a/llvm/test/Analysis/BasicAA/noalias-param.ll
+++ b/llvm/test/Analysis/BasicAA/noalias-param.ll
@@ -22,9 +22,9 @@ entry:
   ret void
 }
 
-; TODO: Result should be the same for byval instead of noalias.
+; Result should be the same for byval instead of noalias.
 ; CHECK-LABEL: byval
-; CHECK: MayAlias: i32* %a, i32* %b
+; CHECK: NoAlias: i32* %a, i32* %b
 define void @byval(i32* byval(i32) %a, i32* %b) nounwind {
 entry:
   store i32 1, i32* %a


        


More information about the llvm-branch-commits mailing list