Skip to content

Commit

Permalink
[Attributor][FIX] Do not ignore memory writes in AAMemoryBehavior
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jdoerfert committed Oct 28, 2021
1 parent 1720787 commit acf3093
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/Attributor/openmp_parallel.ll
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit acf3093

Please sign in to comment.