From 20e2839cb975a2d4ee931e1ea4c4660a36ef0177 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 13 Aug 2008 22:08:30 +0000 Subject: [PATCH] Move r2iMap_ over to DenseMap from std::map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54765 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 20 +++++++++++++++++--- lib/CodeGen/LiveIntervalAnalysis.cpp | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index cf5ad63f095..e12bab18b71 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -55,6 +55,20 @@ namespace llvm { return LHS.first < RHS.first; } }; + + // Provide DenseMapInfo for unsigned. + template<> + struct DenseMapInfo { + static inline unsigned getEmptyKey() { return (unsigned)-1; } + static inline unsigned getTombstoneKey() { return (unsigned)-2; } + static unsigned getHashValue(const unsigned Val) { + return Val * 37; + } + static bool isEqual(const unsigned LHS, const unsigned RHS) { + return LHS == RHS; + } + static bool isPod() { return true; } + }; class LiveIntervals : public MachineFunctionPass { MachineFunction* mf_; @@ -86,7 +100,7 @@ namespace llvm { typedef std::vector Index2MiMap; Index2MiMap i2miMap_; - typedef std::map Reg2IntervalMap; + typedef DenseMap Reg2IntervalMap; Reg2IntervalMap r2iMap_; BitVector allocatableRegs_; @@ -236,7 +250,7 @@ namespace llvm { LiveInterval &getOrCreateInterval(unsigned reg) { Reg2IntervalMap::iterator I = r2iMap_.find(reg); if (I == r2iMap_.end()) - I = r2iMap_.insert(I, std::make_pair(reg, createInterval(reg))); + I = r2iMap_.insert(std::make_pair(reg, createInterval(reg))).first; return *I->second; } @@ -248,7 +262,7 @@ namespace llvm { // Interval removal void removeInterval(unsigned Reg) { - std::map::iterator I = r2iMap_.find(Reg); + DenseMap::iterator I = r2iMap_.find(Reg); delete I->second; r2iMap_.erase(I); } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index db8a5a0f4c1..742ef5c2df9 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -72,7 +72,7 @@ void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const { void LiveIntervals::releaseMemory() { // Free the live intervals themselves. - for (std::map::iterator I = r2iMap_.begin(), + for (DenseMap::iterator I = r2iMap_.begin(), E = r2iMap_.end(); I != E; ++I) delete I->second; -- 2.34.1