Skip to content

Commit

Permalink
[Attributor][FIX] HasBeenWrittenTo logic should only be used for reads
Browse files Browse the repository at this point in the history
If we look at a write, we should not enact the "has been written to"
logic introduced to avoid spurious write -> read dependences. Doing so
lead to elimination of stores we needed, which is obviously bad.
  • Loading branch information
jdoerfert committed Jul 23, 2022
1 parent baec06a commit 6b7eae1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/AttributorAttributes.cpp
Expand Up @@ -1069,7 +1069,7 @@ struct AAPointerInfoImpl
bool Dominates = DT && Exact && Acc.isMustAccess() &&
(Acc.getLocalInst()->getFunction() == &Scope) &&
DT->dominates(Acc.getRemoteInst(), &I);
if (Dominates)
if (FindInterferingWrites && Dominates)
HasBeenWrittenTo = true;

// For now we only filter accesses based on CFG reasoning which does not
Expand Down
Expand Up @@ -2674,6 +2674,7 @@ define i32 @static_global_not_simplifiable_2(i32 %cnd) {
; IS__TUNIT_NPM-NEXT: store i32 1, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__TUNIT_NPM-NEXT: call void @sync() #[[ATTR14:[0-9]+]]
; IS__TUNIT_NPM-NEXT: [[I:%.*]] = load i32, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__TUNIT_NPM-NEXT: store i32 2, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__TUNIT_NPM-NEXT: ret i32 [[I]]
;
; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@static_global_not_simplifiable_2
Expand All @@ -2691,6 +2692,7 @@ define i32 @static_global_not_simplifiable_2(i32 %cnd) {
; IS__CGSCC_NPM-NEXT: store i32 1, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__CGSCC_NPM-NEXT: call void @sync() #[[ATTR16:[0-9]+]]
; IS__CGSCC_NPM-NEXT: [[I:%.*]] = load i32, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__CGSCC_NPM-NEXT: store i32 2, i32* @Flag4, align 4, !tbaa [[TBAA3]]
; IS__CGSCC_NPM-NEXT: ret i32 [[I]]
;
entry:
Expand Down

0 comments on commit 6b7eae1

Please sign in to comment.