forked from OSchip/llvm-project
[DSE] Track overlapping stores.
Add a map from BasicBlocks to overlap intervals. For partial writes, we can keep track of those in IOLs. We only add candidates that are valid for eliminations. Reviewers: dmgreen, bryant, asbirlea, Tyker Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D73757
This commit is contained in:
parent
b4b9706d5d
commit
af69d5e10e
|
@ -1455,6 +1455,10 @@ struct DSEState {
|
|||
// Keep track of blocks with throwing instructions not modeled in MemorySSA.
|
||||
SmallPtrSet<BasicBlock *, 16> ThrowingBlocks;
|
||||
|
||||
/// Keep track of instructions (partly) overlapping with killing MemoryDefs per
|
||||
/// basic block.
|
||||
DenseMap<BasicBlock *, InstOverlapIntervalsTy> IOLs;
|
||||
|
||||
DSEState(Function &F, AliasAnalysis &AA, MemorySSA &MSSA, DominatorTree &DT,
|
||||
PostDominatorTree &PDT, const TargetLibraryInfo &TLI)
|
||||
: F(F), AA(AA), MSSA(MSSA), DT(DT), PDT(PDT), TLI(TLI) {}
|
||||
|
@ -1684,6 +1688,9 @@ struct DSEState {
|
|||
Updater.removeMemoryAccess(MA);
|
||||
}
|
||||
|
||||
auto I = IOLs.find(DeadInst->getParent());
|
||||
if (I != IOLs.end())
|
||||
I->second.erase(DeadInst);
|
||||
// Remove its operands
|
||||
for (Use &O : DeadInst->operands())
|
||||
if (Instruction *OpI = dyn_cast<Instruction>(O)) {
|
||||
|
@ -1804,7 +1811,10 @@ bool eliminateDeadStoresMemorySSA(Function &F, AliasAnalysis &AA,
|
|||
|
||||
// Check if NI overwrites SI.
|
||||
int64_t InstWriteOffset, DepWriteOffset;
|
||||
InstOverlapIntervalsTy IOL;
|
||||
auto Iter = State.IOLs.insert(
|
||||
std::make_pair<BasicBlock *, InstOverlapIntervalsTy>(
|
||||
NI->getParent(), InstOverlapIntervalsTy()));
|
||||
auto &IOL = Iter.first->second;
|
||||
OverwriteResult OR = isOverwrite(SILoc, NILoc, DL, TLI, DepWriteOffset,
|
||||
InstWriteOffset, NI, IOL, AA, &F);
|
||||
|
||||
|
@ -1819,6 +1829,10 @@ bool eliminateDeadStoresMemorySSA(Function &F, AliasAnalysis &AA,
|
|||
}
|
||||
}
|
||||
|
||||
if (EnablePartialOverwriteTracking)
|
||||
for (auto &KV : State.IOLs)
|
||||
MadeChange |= removePartiallyOverlappedStores(&AA, DL, KV.second);
|
||||
|
||||
return MadeChange;
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; XFAIL: *
|
||||
; RUN: opt < %s -basicaa -dse -enable-dse-memoryssa -S | FileCheck %s
|
||||
|
||||
define void @write4to7(i32* nocapture %p) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; XFAIL: *
|
||||
; RUN: opt < %s -basicaa -dse -enable-dse-memoryssa -S | FileCheck %s
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
; Test that the getelementptr generated when the dse pass determines that
|
||||
; a memset can be shortened has the debugloc carried over from the memset.
|
||||
|
||||
; XFAIL: *
|
||||
; RUN: opt -S -march=native -dse -enable-dse-memoryssa < %s| FileCheck %s
|
||||
; CHECK: bitcast [5 x i64]* %{{[a-zA-Z_][a-zA-Z0-9_]*}} to i8*, !dbg
|
||||
; CHECK-NEXT: %{{[0-9]+}} = getelementptr inbounds i8, i8* %0, i64 32, !dbg ![[DBG:[0-9]+]]
|
||||
|
|
|
@ -248,7 +248,6 @@ end:
|
|||
; We cannot eliminate the store in for.header, as the location is not overwritten
|
||||
; in for.body and read afterwards.
|
||||
define void @loop_multiple_def_uses_mayalias_write(i32* %p, i32* %q) {
|
||||
|
||||
; CHECK-LABEL: @loop_multiple_def_uses_mayalias_write(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: br label [[FOR_HEADER:%.*]]
|
||||
|
|
|
@ -43,7 +43,8 @@ define void @test20(i32* noalias %P) {
|
|||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[ARRAYIDX0:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 1
|
||||
; CHECK-NEXT: [[P3:%.*]] = bitcast i32* [[ARRAYIDX0]] to i8*
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[P3]], i8 0, i64 28, i1 false)
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i8, i8* [[P3]], i64 4
|
||||
; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[TMP0]], i8 0, i64 24, i1 false)
|
||||
; CHECK-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
|
||||
; CHECK: bb1:
|
||||
; CHECK-NEXT: br label [[BB3:%.*]]
|
||||
|
|
Loading…
Reference in New Issue