forked from OSchip/llvm-project
[MemorySSA] Make sure PerformedPhiTrans is updated for each visited def.
1ce82015f6
added a fix to restrict phi optimizations after phi
translations. But the current use of performedPhiTranslation only
checked whether phi translation happened for the first iterator and
missed cases where phi translations happens at subsequent
iterators/upwards defs.
This patch changes upward_defs_iteartor to take a pointer to a bool, so
we can easily ensure the final value includes all visited defs, while
still being able to conveniently use it with make_range & co.
This commit is contained in:
parent
f07f3c7237
commit
c4f1b31441
|
@ -1181,9 +1181,11 @@ class upward_defs_iterator
|
||||||
using BaseT = upward_defs_iterator::iterator_facade_base;
|
using BaseT = upward_defs_iterator::iterator_facade_base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
upward_defs_iterator(const MemoryAccessPair &Info, DominatorTree *DT)
|
upward_defs_iterator(const MemoryAccessPair &Info, DominatorTree *DT,
|
||||||
|
bool *PerformedPhiTranslation = nullptr)
|
||||||
: DefIterator(Info.first), Location(Info.second),
|
: DefIterator(Info.first), Location(Info.second),
|
||||||
OriginalAccess(Info.first), DT(DT) {
|
OriginalAccess(Info.first), DT(DT),
|
||||||
|
PerformedPhiTranslation(PerformedPhiTranslation) {
|
||||||
CurrentPair.first = nullptr;
|
CurrentPair.first = nullptr;
|
||||||
|
|
||||||
WalkingPhi = Info.first && isa<MemoryPhi>(Info.first);
|
WalkingPhi = Info.first && isa<MemoryPhi>(Info.first);
|
||||||
|
@ -1214,8 +1216,6 @@ public:
|
||||||
|
|
||||||
BasicBlock *getPhiArgBlock() const { return DefIterator.getPhiArgBlock(); }
|
BasicBlock *getPhiArgBlock() const { return DefIterator.getPhiArgBlock(); }
|
||||||
|
|
||||||
bool performedPhiTranslation() const { return PerformedPhiTranslation; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fillInCurrentPair() {
|
void fillInCurrentPair() {
|
||||||
CurrentPair.first = *DefIterator;
|
CurrentPair.first = *DefIterator;
|
||||||
|
@ -1228,7 +1228,8 @@ private:
|
||||||
false)) {
|
false)) {
|
||||||
if (Translator.getAddr() != Location.Ptr) {
|
if (Translator.getAddr() != Location.Ptr) {
|
||||||
CurrentPair.second = Location.getWithNewPtr(Translator.getAddr());
|
CurrentPair.second = Location.getWithNewPtr(Translator.getAddr());
|
||||||
PerformedPhiTranslation = true;
|
if (PerformedPhiTranslation)
|
||||||
|
*PerformedPhiTranslation = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1245,12 +1246,13 @@ private:
|
||||||
MemoryAccess *OriginalAccess = nullptr;
|
MemoryAccess *OriginalAccess = nullptr;
|
||||||
DominatorTree *DT = nullptr;
|
DominatorTree *DT = nullptr;
|
||||||
bool WalkingPhi = false;
|
bool WalkingPhi = false;
|
||||||
bool PerformedPhiTranslation = false;
|
bool *PerformedPhiTranslation = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline upward_defs_iterator upward_defs_begin(const MemoryAccessPair &Pair,
|
inline upward_defs_iterator
|
||||||
DominatorTree &DT) {
|
upward_defs_begin(const MemoryAccessPair &Pair, DominatorTree &DT,
|
||||||
return upward_defs_iterator(Pair, &DT);
|
bool *PerformedPhiTranslation = nullptr) {
|
||||||
|
return upward_defs_iterator(Pair, &DT, PerformedPhiTranslation);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline upward_defs_iterator upward_defs_end() { return upward_defs_iterator(); }
|
inline upward_defs_iterator upward_defs_end() { return upward_defs_iterator(); }
|
||||||
|
|
|
@ -603,13 +603,13 @@ template <class AliasAnalysisType> class ClobberWalker {
|
||||||
|
|
||||||
void addSearches(MemoryPhi *Phi, SmallVectorImpl<ListIndex> &PausedSearches,
|
void addSearches(MemoryPhi *Phi, SmallVectorImpl<ListIndex> &PausedSearches,
|
||||||
ListIndex PriorNode) {
|
ListIndex PriorNode) {
|
||||||
auto UpwardDefsBegin = upward_defs_begin({Phi, Paths[PriorNode].Loc}, DT);
|
auto UpwardDefsBegin = upward_defs_begin({Phi, Paths[PriorNode].Loc}, DT,
|
||||||
|
&PerformedPhiTranslation);
|
||||||
auto UpwardDefs = make_range(UpwardDefsBegin, upward_defs_end());
|
auto UpwardDefs = make_range(UpwardDefsBegin, upward_defs_end());
|
||||||
for (const MemoryAccessPair &P : UpwardDefs) {
|
for (const MemoryAccessPair &P : UpwardDefs) {
|
||||||
PausedSearches.push_back(Paths.size());
|
PausedSearches.push_back(Paths.size());
|
||||||
Paths.emplace_back(P.second, P.first, PriorNode);
|
Paths.emplace_back(P.second, P.first, PriorNode);
|
||||||
}
|
}
|
||||||
PerformedPhiTranslation |= UpwardDefsBegin.performedPhiTranslation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a search that terminated after finding a clobber. This clobber
|
/// Represents a search that terminated after finding a clobber. This clobber
|
||||||
|
|
|
@ -384,10 +384,9 @@ define void @dont_merge_noalias_complex_2(i32 %arg, i32 %arg1) {
|
||||||
; CHECK-NEXT: call void @init([32 x i32]* %tmp)
|
; CHECK-NEXT: call void @init([32 x i32]* %tmp)
|
||||||
|
|
||||||
; CHECK-LABEL: loop.1.header:
|
; CHECK-LABEL: loop.1.header:
|
||||||
; CHECK-NEXT: ; 4 = MemoryPhi({entry,1},{loop.1.latch,3})
|
; CHECK-NEXT: ; 4 = MemoryPhi({entry,1},{loop.1.latch,3})
|
||||||
; NOLIMIT: ; MemoryUse(1) MayAlias
|
; CHECK: ; MemoryUse(4) MayAlias
|
||||||
; LIMIT: ; MemoryUse(4) MayAlias
|
; CHECK-NEXT: %l.1 = load i32, i32* %p.1, align 4
|
||||||
; CHECK-NEXT: %l.1 = load i32, i32* %p.1, align 4
|
|
||||||
|
|
||||||
; CHECK-LABEL: loop.1.latch:
|
; CHECK-LABEL: loop.1.latch:
|
||||||
; CHECK-NEXT: ; 3 = MemoryPhi({loop.1.header,4},{storebb,2})
|
; CHECK-NEXT: ; 3 = MemoryPhi({loop.1.header,4},{storebb,2})
|
||||||
|
|
Loading…
Reference in New Issue