diff options
-rw-r--r-- | include/llvm/CodeGen/LiveIntervalAnalysis.h | 13 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.cpp | 8 | ||||
-rw-r--r-- | lib/CodeGen/LiveIntervalAnalysis.h | 13 |
3 files changed, 19 insertions, 15 deletions
diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 73d730a647..b90be62704 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -20,6 +20,7 @@ #ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H #define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H +#include "llvm/ADT/DenseMap.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "LiveInterval.h" @@ -44,7 +45,7 @@ namespace llvm { typedef std::map<unsigned, LiveInterval> Reg2IntervalMap; Reg2IntervalMap r2iMap_; - typedef std::map<unsigned, unsigned> Reg2RegMap; + typedef DenseMap<unsigned> Reg2RegMap; Reg2RegMap r2rMap_; std::vector<bool> allocatableRegs_; @@ -171,11 +172,11 @@ namespace llvm { } /// rep - returns the representative of this register - unsigned rep(unsigned reg) { - Reg2RegMap::iterator it = r2rMap_.find(reg); - if (it != r2rMap_.end()) - return it->second = rep(it->second); - return reg; + unsigned rep(unsigned Reg) { + unsigned Rep = r2rMap_[Reg]; + if (Rep) + return r2rMap_[Reg] = rep(Rep); + return Reg; } void printRegName(unsigned reg) const; diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 3ebd907586..e0fefc3870 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -619,6 +619,8 @@ namespace { void LiveIntervals::joinIntervals() { DEBUG(std::cerr << "********** JOINING INTERVALS ***********\n"); + // reserve space for the reg2reg map + r2rMap_.grow(mf_->getSSARegMap()->getLastVirtReg()); const LoopInfo &LI = getAnalysis<LoopInfo>(); if (LI.begin() == LI.end()) { @@ -644,9 +646,9 @@ void LiveIntervals::joinIntervals() { } DEBUG(std::cerr << "*** Register mapping ***\n"); - DEBUG(for (std::map<unsigned, unsigned>::iterator I = r2rMap_.begin(), - E = r2rMap_.end(); I != E; ++I) - std::cerr << " reg " << I->first << " -> reg " << I->second << "\n";); + DEBUG(for (int i = 0, e = r2rMap_.size(); i != e; ++i) + if (r2rMap_[i]) + std::cerr << " reg " << i << " -> reg " << r2rMap_[i] << "\n"); } /// Return true if the two specified registers belong to different register diff --git a/lib/CodeGen/LiveIntervalAnalysis.h b/lib/CodeGen/LiveIntervalAnalysis.h index 73d730a647..b90be62704 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.h +++ b/lib/CodeGen/LiveIntervalAnalysis.h @@ -20,6 +20,7 @@ #ifndef LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H #define LLVM_CODEGEN_LIVEINTERVAL_ANALYSIS_H +#include "llvm/ADT/DenseMap.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "LiveInterval.h" @@ -44,7 +45,7 @@ namespace llvm { typedef std::map<unsigned, LiveInterval> Reg2IntervalMap; Reg2IntervalMap r2iMap_; - typedef std::map<unsigned, unsigned> Reg2RegMap; + typedef DenseMap<unsigned> Reg2RegMap; Reg2RegMap r2rMap_; std::vector<bool> allocatableRegs_; @@ -171,11 +172,11 @@ namespace llvm { } /// rep - returns the representative of this register - unsigned rep(unsigned reg) { - Reg2RegMap::iterator it = r2rMap_.find(reg); - if (it != r2rMap_.end()) - return it->second = rep(it->second); - return reg; + unsigned rep(unsigned Reg) { + unsigned Rep = r2rMap_[Reg]; + if (Rep) + return r2rMap_[Reg] = rep(Rep); + return Reg; } void printRegName(unsigned reg) const; |