[llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervalAnalysis.h LiveIntervalAnalysis.cpp
Alkis Evlogimenos
alkis at cs.uiuc.edu
Tue Sep 7 20:02:00 PDT 2004
Changes in directory llvm/lib/CodeGen:
LiveIntervalAnalysis.h updated: 1.41 -> 1.42
LiveIntervalAnalysis.cpp updated: 1.124 -> 1.125
---
Log message:
Use a DenseMap for mapping reg->reg. This improves the LiveInterval
analysis running time from 2.7869secs to 2.5226secs on 176.gcc.
---
Diffs of the changes: (+12 -9)
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.h
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.41 llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.42
--- llvm/lib/CodeGen/LiveIntervalAnalysis.h:1.41 Thu Aug 26 17:22:38 2004
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.h Tue Sep 7 22:01:50 2004
@@ -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 @@
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 @@
}
/// 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;
Index: llvm/lib/CodeGen/LiveIntervalAnalysis.cpp
diff -u llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.124 llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.125
--- llvm/lib/CodeGen/LiveIntervalAnalysis.cpp:1.124 Fri Sep 3 13:25:53 2004
+++ llvm/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Sep 7 22:01:50 2004
@@ -619,6 +619,8 @@
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 @@
}
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
More information about the llvm-commits
mailing list