copies being considered for removal. Make sure to track all of the copies,
rather than just the most recent encountered, by holding a DenseSet instead of
an unsigned in SrcMap.
No test case - couldn't reduce something with a sane size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153487
91177308-0d34-0410-b5e6-
96231b3b80d8
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
private:
void SourceNoLongerAvailable(unsigned Reg,
private:
void SourceNoLongerAvailable(unsigned Reg,
- DenseMap<unsigned, unsigned> &SrcMap,
+ DenseMap<unsigned, DenseSet<unsigned> > &SrcMap,
DenseMap<unsigned, MachineInstr*> &AvailCopyMap);
bool CopyPropagateBlock(MachineBasicBlock &MBB);
};
DenseMap<unsigned, MachineInstr*> &AvailCopyMap);
bool CopyPropagateBlock(MachineBasicBlock &MBB);
};
void
MachineCopyPropagation::SourceNoLongerAvailable(unsigned Reg,
void
MachineCopyPropagation::SourceNoLongerAvailable(unsigned Reg,
- DenseMap<unsigned, unsigned> &SrcMap,
+ DenseMap<unsigned, DenseSet<unsigned> > &SrcMap,
DenseMap<unsigned, MachineInstr*> &AvailCopyMap) {
DenseMap<unsigned, MachineInstr*> &AvailCopyMap) {
- DenseMap<unsigned, unsigned>::iterator SI = SrcMap.find(Reg);
+ DenseMap<unsigned, DenseSet<unsigned> >::iterator SI = SrcMap.find(Reg);
if (SI != SrcMap.end()) {
if (SI != SrcMap.end()) {
- unsigned MappedDef = SI->second;
- // Source of copy is no longer available for propagation.
- if (AvailCopyMap.erase(MappedDef)) {
- for (const uint16_t *SR = TRI->getSubRegisters(MappedDef); *SR; ++SR)
- AvailCopyMap.erase(*SR);
+ const DenseSet<unsigned>& Defs = SI->second;
+ for (DenseSet<unsigned>::const_iterator I = Defs.begin(), E = Defs.end();
+ I != E; ++I) {
+ unsigned MappedDef = *I;
+ // Source of copy is no longer available for propagation.
+ if (AvailCopyMap.erase(MappedDef)) {
+ for (const uint16_t *SR = TRI->getSubRegisters(MappedDef); *SR; ++SR)
+ AvailCopyMap.erase(*SR);
+ }
}
}
for (const uint16_t *AS = TRI->getAliasSet(Reg); *AS; ++AS) {
SI = SrcMap.find(*AS);
if (SI != SrcMap.end()) {
}
}
for (const uint16_t *AS = TRI->getAliasSet(Reg); *AS; ++AS) {
SI = SrcMap.find(*AS);
if (SI != SrcMap.end()) {
- unsigned MappedDef = SI->second;
- if (AvailCopyMap.erase(MappedDef)) {
- for (const uint16_t *SR = TRI->getSubRegisters(MappedDef); *SR; ++SR)
- AvailCopyMap.erase(*SR);
+ const DenseSet<unsigned>& Defs = SI->second;
+ for (DenseSet<unsigned>::const_iterator I = Defs.begin(), E = Defs.end();
+ I != E; ++I) {
+ unsigned MappedDef = *I;
+ if (AvailCopyMap.erase(MappedDef)) {
+ for (const uint16_t *SR = TRI->getSubRegisters(MappedDef); *SR; ++SR)
+ AvailCopyMap.erase(*SR);
+ }
}
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
}
bool MachineCopyPropagation::CopyPropagateBlock(MachineBasicBlock &MBB) {
- SmallSetVector<MachineInstr*, 8> MaybeDeadCopies; // Candidates for deletion
- DenseMap<unsigned, MachineInstr*> AvailCopyMap; // Def -> available copies map
- DenseMap<unsigned, MachineInstr*> CopyMap; // Def -> copies map
- DenseMap<unsigned, unsigned> SrcMap; // Src -> Def map
+ SmallSetVector<MachineInstr*, 8> MaybeDeadCopies; // Candidates for deletion
+ DenseMap<unsigned, MachineInstr*> AvailCopyMap; // Def -> available copies map
+ DenseMap<unsigned, MachineInstr*> CopyMap; // Def -> copies map
+ DenseMap<unsigned, DenseSet<unsigned> > SrcMap; // Src -> Def map
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ) {
bool Changed = false;
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ) {
// Remember source that's copied to Def. Once it's clobbered, then
// it's no longer available for copy propagation.
// Remember source that's copied to Def. Once it's clobbered, then
// it's no longer available for copy propagation.
+ SrcMap[Src].insert(Def);