[llvm] acf3093 - [Attributor][FIX] Do not ignore memory writes in AAMemoryBehavior

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 27 19:04:53 PDT 2021


Author: Johannes Doerfert
Date: 2021-10-27T21:04:32-05:00
New Revision: acf3093117e354c7cdf097600cd406a16720804d

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

LOG: [Attributor][FIX] Do not ignore memory writes in AAMemoryBehavior

Even if we look for `nocapture` we need to bail on escaping pointers.
The crucial thing is that we might not look at a big enough scope when
we derive the memory behavior. Thus, it might be `nocapture` in a larger
context while it is "captured" in a smaller context.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    llvm/test/Transforms/Attributor/openmp_parallel.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index c89bda73a263..06f399129f3c 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7322,10 +7322,12 @@ void AAMemoryBehaviorFloating::analyzeUseIn(Attributor &A, const Use &U,
 
   case Instruction::Store:
     // Stores cause the NO_WRITES property to disappear if the use is the
-    // pointer operand. Note that we do assume that capturing was taken care of
-    // somewhere else.
+    // pointer operand. Note that while capturing was taken care of somewhere
+    // else we need to deal with stores of the value that is not looked through.
     if (cast<StoreInst>(UserI)->getPointerOperand() == U.get())
       removeAssumedBits(NO_WRITES);
+    else
+      indicatePessimisticFixpoint();
     return;
 
   case Instruction::Call:

diff  --git a/llvm/test/Transforms/Attributor/openmp_parallel.ll b/llvm/test/Transforms/Attributor/openmp_parallel.ll
index 6d48cbea4e38..0d73bc29593e 100644
--- a/llvm/test/Transforms/Attributor/openmp_parallel.ll
+++ b/llvm/test/Transforms/Attributor/openmp_parallel.ll
@@ -49,7 +49,7 @@ define dso_local void @func(float* nocapture %a, float* %b, i32 %N) local_unname
 ;
 ; IS__CGSCC_OPM: Function Attrs: nounwind uwtable
 ; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@func
-; IS__CGSCC_OPM-SAME: (float* nocapture nofree readnone [[A:%.*]], float* nofree [[B:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; IS__CGSCC_OPM-SAME: (float* nocapture nofree [[A:%.*]], float* nofree [[B:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
 ; IS__CGSCC_OPM-NEXT:  entry:
 ; IS__CGSCC_OPM-NEXT:    [[A_ADDR:%.*]] = alloca float*, align 8
 ; IS__CGSCC_OPM-NEXT:    [[B_ADDR:%.*]] = alloca float*, align 8
@@ -62,7 +62,7 @@ define dso_local void @func(float* nocapture %a, float* %b, i32 %N) local_unname
 ;
 ; IS__CGSCC_NPM: Function Attrs: nounwind uwtable
 ; IS__CGSCC_NPM-LABEL: define {{[^@]+}}@func
-; IS__CGSCC_NPM-SAME: (float* nocapture nofree readnone [[A:%.*]], float* nofree [[B:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; IS__CGSCC_NPM-SAME: (float* nocapture nofree [[A:%.*]], float* nofree [[B:%.*]], i32 [[N:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
 ; IS__CGSCC_NPM-NEXT:  entry:
 ; IS__CGSCC_NPM-NEXT:    [[A_ADDR:%.*]] = alloca float*, align 8
 ; IS__CGSCC_NPM-NEXT:    [[B_ADDR:%.*]] = alloca float*, align 8


        


More information about the llvm-commits mailing list