[Attributor][FIX] HasBeenWrittenTo logic should only be used for reads

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.
This commit is contained in:
Johannes Doerfert 2022-07-22 23:56:12 -05:00
parent baec06a9d4
commit 6b7eae11f1
2 changed files with 3 additions and 1 deletions
llvm
lib/Transforms/IPO
test/Transforms/Attributor

View File

@ -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

View File

@ -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
@ -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: