Revert "MemorySSA: Add support for caching clobbering access in stores"
This reverts revision r299322. llvm-svn: 299485
This commit is contained in:
parent
880cfd45fc
commit
f49d4c45a1
|
@ -246,16 +246,6 @@ public:
|
||||||
return MA->getValueID() == MemoryUseVal || MA->getValueID() == MemoryDefVal;
|
return MA->getValueID() == MemoryUseVal || MA->getValueID() == MemoryDefVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sadly, these have to be public because they are needed in some of the iterators.
|
|
||||||
virtual bool isOptimized() const = 0;
|
|
||||||
virtual MemoryAccess *getOptimized() const = 0;
|
|
||||||
virtual void setOptimized(MemoryAccess *) = 0;
|
|
||||||
|
|
||||||
/// \brief Reset the ID of what this MemoryUse was optimized to, causing it to
|
|
||||||
/// be rewalked by the walker if necessary.
|
|
||||||
/// This really should only be called by tests.
|
|
||||||
virtual void resetOptimized() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class MemorySSA;
|
friend class MemorySSA;
|
||||||
friend class MemorySSAUpdater;
|
friend class MemorySSAUpdater;
|
||||||
|
@ -264,12 +254,8 @@ protected:
|
||||||
: MemoryAccess(C, Vty, BB, 1), MemoryInst(MI) {
|
: MemoryAccess(C, Vty, BB, 1), MemoryInst(MI) {
|
||||||
setDefiningAccess(DMA);
|
setDefiningAccess(DMA);
|
||||||
}
|
}
|
||||||
void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false) {
|
|
||||||
setOperand(0, DMA);
|
void setDefiningAccess(MemoryAccess *DMA) { setOperand(0, DMA); }
|
||||||
if (!Optimized)
|
|
||||||
return;
|
|
||||||
setOptimized(DMA);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Instruction *MemoryInst;
|
Instruction *MemoryInst;
|
||||||
|
@ -302,18 +288,20 @@ public:
|
||||||
|
|
||||||
void print(raw_ostream &OS) const override;
|
void print(raw_ostream &OS) const override;
|
||||||
|
|
||||||
virtual void setOptimized(MemoryAccess *DMA) override {
|
void setDefiningAccess(MemoryAccess *DMA, bool Optimized = false) {
|
||||||
OptimizedID = DMA->getID();
|
if (Optimized)
|
||||||
|
OptimizedID = DMA->getID();
|
||||||
|
MemoryUseOrDef::setDefiningAccess(DMA);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isOptimized() const override {
|
bool isOptimized() const {
|
||||||
return getDefiningAccess() && OptimizedID == getDefiningAccess()->getID();
|
return getDefiningAccess() && OptimizedID == getDefiningAccess()->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual MemoryAccess *getOptimized() const override {
|
/// \brief Reset the ID of what this MemoryUse was optimized to, causing it to
|
||||||
return getDefiningAccess();
|
/// be rewalked by the walker if necessary.
|
||||||
}
|
/// This really should only be called by tests.
|
||||||
virtual void resetOptimized() override { OptimizedID = INVALID_MEMORYACCESS_ID; }
|
void resetOptimized() { OptimizedID = INVALID_MEMORYACCESS_ID; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class MemorySSA;
|
friend class MemorySSA;
|
||||||
|
@ -345,8 +333,7 @@ public:
|
||||||
|
|
||||||
MemoryDef(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB,
|
MemoryDef(LLVMContext &C, MemoryAccess *DMA, Instruction *MI, BasicBlock *BB,
|
||||||
unsigned Ver)
|
unsigned Ver)
|
||||||
: MemoryUseOrDef(C, DMA, MemoryDefVal, MI, BB), ID(Ver),
|
: MemoryUseOrDef(C, DMA, MemoryDefVal, MI, BB), ID(Ver) {}
|
||||||
Optimized(nullptr), OptimizedID(INVALID_MEMORYACCESS_ID) {}
|
|
||||||
|
|
||||||
// allocate space for exactly one operand
|
// allocate space for exactly one operand
|
||||||
void *operator new(size_t s) { return User::operator new(s, 1); }
|
void *operator new(size_t s) { return User::operator new(s, 1); }
|
||||||
|
@ -356,17 +343,6 @@ public:
|
||||||
return MA->getValueID() == MemoryDefVal;
|
return MA->getValueID() == MemoryDefVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setOptimized(MemoryAccess *MA) override {
|
|
||||||
Optimized = MA;
|
|
||||||
OptimizedID = getDefiningAccess()->getID();
|
|
||||||
}
|
|
||||||
virtual MemoryAccess *getOptimized() const override { return Optimized; }
|
|
||||||
virtual bool isOptimized() const override {
|
|
||||||
return getOptimized() && OptimizedID == getDefiningAccess()->getID();
|
|
||||||
}
|
|
||||||
virtual void resetOptimized() override { OptimizedID = INVALID_MEMORYACCESS_ID; }
|
|
||||||
|
|
||||||
|
|
||||||
void print(raw_ostream &OS) const override;
|
void print(raw_ostream &OS) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -376,8 +352,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const unsigned ID;
|
const unsigned ID;
|
||||||
MemoryAccess *Optimized;
|
|
||||||
unsigned int OptimizedID;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -1101,15 +1075,10 @@ struct def_chain_iterator
|
||||||
|
|
||||||
def_chain_iterator &operator++() {
|
def_chain_iterator &operator++() {
|
||||||
// N.B. liveOnEntry has a null defining access.
|
// N.B. liveOnEntry has a null defining access.
|
||||||
if (auto *MUD = dyn_cast<MemoryUseOrDef>(MA)) {
|
if (auto *MUD = dyn_cast<MemoryUseOrDef>(MA))
|
||||||
if (MUD->isOptimized())
|
MA = MUD->getDefiningAccess();
|
||||||
MA = MUD->getOptimized();
|
else
|
||||||
else
|
|
||||||
MA = MUD->getDefiningAccess();
|
|
||||||
} else {
|
|
||||||
MA = nullptr;
|
MA = nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2181,9 +2181,9 @@ MemorySSA::CachingWalker::getClobberingMemoryAccess(MemoryAccess *MA) {
|
||||||
// If this is an already optimized use or def, return the optimized result.
|
// If this is an already optimized use or def, return the optimized result.
|
||||||
// Note: Currently, we do not store the optimized def result because we'd need
|
// Note: Currently, we do not store the optimized def result because we'd need
|
||||||
// a separate field, since we can't use it as the defining access.
|
// a separate field, since we can't use it as the defining access.
|
||||||
if (auto *MUD = dyn_cast<MemoryUseOrDef>(StartingAccess))
|
if (MemoryUse *MU = dyn_cast<MemoryUse>(StartingAccess))
|
||||||
if (MUD->isOptimized())
|
if (MU->isOptimized())
|
||||||
return MUD->getOptimized();
|
return MU->getDefiningAccess();
|
||||||
|
|
||||||
const Instruction *I = StartingAccess->getMemoryInst();
|
const Instruction *I = StartingAccess->getMemoryInst();
|
||||||
UpwardsMemoryQuery Q(I, StartingAccess);
|
UpwardsMemoryQuery Q(I, StartingAccess);
|
||||||
|
@ -2199,8 +2199,8 @@ MemorySSA::CachingWalker::getClobberingMemoryAccess(MemoryAccess *MA) {
|
||||||
if (isUseTriviallyOptimizableToLiveOnEntry(*MSSA->AA, I)) {
|
if (isUseTriviallyOptimizableToLiveOnEntry(*MSSA->AA, I)) {
|
||||||
MemoryAccess *LiveOnEntry = MSSA->getLiveOnEntryDef();
|
MemoryAccess *LiveOnEntry = MSSA->getLiveOnEntryDef();
|
||||||
Cache.insert(StartingAccess, LiveOnEntry, Q.StartingLoc, Q.IsCall);
|
Cache.insert(StartingAccess, LiveOnEntry, Q.StartingLoc, Q.IsCall);
|
||||||
if (auto *MUD = dyn_cast<MemoryUseOrDef>(StartingAccess))
|
if (MemoryUse *MU = dyn_cast<MemoryUse>(StartingAccess))
|
||||||
MUD->setDefiningAccess(LiveOnEntry, true);
|
MU->setDefiningAccess(LiveOnEntry, true);
|
||||||
return LiveOnEntry;
|
return LiveOnEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2217,8 +2217,8 @@ MemorySSA::CachingWalker::getClobberingMemoryAccess(MemoryAccess *MA) {
|
||||||
DEBUG(dbgs() << *DefiningAccess << "\n");
|
DEBUG(dbgs() << *DefiningAccess << "\n");
|
||||||
DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is ");
|
DEBUG(dbgs() << "Final Memory SSA clobber for " << *I << " is ");
|
||||||
DEBUG(dbgs() << *Result << "\n");
|
DEBUG(dbgs() << *Result << "\n");
|
||||||
if (auto *MUD = dyn_cast<MemoryUseOrDef>(StartingAccess))
|
if (MemoryUse *MU = dyn_cast<MemoryUse>(StartingAccess))
|
||||||
MUD->setDefiningAccess(Result, true);
|
MU->setDefiningAccess(Result, true);
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,8 +451,8 @@ void MemorySSAUpdater::removeMemoryAccess(MemoryAccess *MA) {
|
||||||
|
|
||||||
while (!MA->use_empty()) {
|
while (!MA->use_empty()) {
|
||||||
Use &U = *MA->use_begin();
|
Use &U = *MA->use_begin();
|
||||||
if (auto *MUD = dyn_cast<MemoryUseOrDef>(U.getUser()))
|
if (MemoryUse *MU = dyn_cast<MemoryUse>(U.getUser()))
|
||||||
MUD->resetOptimized();
|
MU->resetOptimized();
|
||||||
U.set(NewDefTarget);
|
U.set(NewDefTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue