Use find with std::map, when that's what's needed, instead of lower_bound
authorDan Gohman <gohman@apple.com>
Wed, 9 Jul 2008 19:51:00 +0000 (19:51 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 9 Jul 2008 19:51:00 +0000 (19:51 +0000)
with extra checks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53344 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAllocLocal.cpp
lib/CodeGen/RegAllocSimple.cpp

index ed45961db9186d1af107f9394ef90505ca93f632..7acf982bdf86ed06dc68d051357d92da440c8c9c 100644 (file)
@@ -250,9 +250,9 @@ namespace {
 /// to be held on the stack.
 int RALocal::getStackSpaceFor(unsigned VirtReg, const TargetRegisterClass *RC) {
   // Find the location Reg would belong...
-  std::map<unsigned, int>::iterator I =StackSlotForVirtReg.lower_bound(VirtReg);
+  std::map<unsigned, int>::iterator I = StackSlotForVirtReg.find(VirtReg);
 
-  if (I != StackSlotForVirtReg.end() && I->first == VirtReg)
+  if (I != StackSlotForVirtReg.end())
     return I->second;          // Already has space allocated?
 
   // Allocate a new stack object for this spill location...
index 081edd8d5eb8b0a5f8b3b2c8bbe36e4b3687a44e..f07f7f92be84a2e7ea16089b9131b86b72376bc1 100644 (file)
@@ -103,10 +103,9 @@ namespace {
 int RegAllocSimple::getStackSpaceFor(unsigned VirtReg,
                                      const TargetRegisterClass *RC) {
   // Find the location VirtReg would belong...
-  std::map<unsigned, int>::iterator I =
-    StackSlotForVirtReg.lower_bound(VirtReg);
+  std::map<unsigned, int>::iterator I = StackSlotForVirtReg.find(VirtReg);
 
-  if (I != StackSlotForVirtReg.end() && I->first == VirtReg)
+  if (I != StackSlotForVirtReg.end())
     return I->second;          // Already has space allocated?
 
   // Allocate a new stack object for this spill location...