aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-09-30 16:35:08 +0000
committerChris Lattner <sabre@nondot.org>2004-09-30 16:35:08 +0000
commitdbea9731b12e62f70d9da40cf273cdd9105f987c (patch)
treec29a8542496d12a0372f3b9c0e3df39a53ed85e6 /lib
parent477e4555de341c5de780de3720d6f115ec133c4e (diff)
downloadexternal_llvm-dbea9731b12e62f70d9da40cf273cdd9105f987c.zip
external_llvm-dbea9731b12e62f70d9da40cf273cdd9105f987c.tar.gz
external_llvm-dbea9731b12e62f70d9da40cf273cdd9105f987c.tar.bz2
Use more efficient map operations. Fix a bug that would affect hypothetical
targets that supported multiple memory operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16614 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/VirtRegMap.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp
index 4d7c826..b687c57 100644
--- a/lib/CodeGen/VirtRegMap.cpp
+++ b/lib/CodeGen/VirtRegMap.cpp
@@ -79,17 +79,19 @@ void VirtRegMap::virtFolded(unsigned virtReg,
MachineInstr* oldMI,
MachineInstr* newMI) {
// move previous memory references folded to new instruction
- MI2VirtMapTy::iterator i, e;
std::vector<MI2VirtMapTy::mapped_type> regs;
- for (tie(i, e) = MI2VirtMap.equal_range(oldMI); i != e; ) {
- regs.push_back(i->second);
- MI2VirtMap.erase(i++);
+ for (MI2VirtMapTy::iterator I = MI2VirtMap.lower_bound(oldMI),
+ E = MI2VirtMap.end(); I != E && I->first == oldMI; ) {
+ regs.push_back(I->second);
+ MI2VirtMap.erase(I++);
}
+
+ MI2VirtMapTy::iterator IP = MI2VirtMap.lower_bound(newMI);
for (unsigned i = 0, e = regs.size(); i != e; ++i)
- MI2VirtMap.insert(std::make_pair(newMI, i));
+ MI2VirtMap.insert(IP, std::make_pair(newMI, regs[i]));
// add new memory reference
- MI2VirtMap.insert(std::make_pair(newMI, virtReg));
+ MI2VirtMap.insert(IP, std::make_pair(newMI, virtReg));
}
void VirtRegMap::print(std::ostream &OS) const {