aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Writer/SlotCalculator.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-10 05:13:03 +0000
committerChris Lattner <sabre@nondot.org>2007-02-10 05:13:03 +0000
commita2bdad49c9c003c6fe7d4416090817a8466f2bb2 (patch)
tree2066a070a05d277ce125580b90129c1bd4674eeb /lib/Bytecode/Writer/SlotCalculator.cpp
parent8183cf62f6f9631a4a32efc7e27880c475777089 (diff)
getSlot can never fail. Make it assert internally, eliminate checks in
clients. Same for getTypeSlot. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34128 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Writer/SlotCalculator.cpp')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index d4c16e9bac..1693ec4681 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -278,25 +278,21 @@ void SlotCalculator::purgeFunction() {
SC_DEBUG("end purgeFunction!\n");
}
-int SlotCalculator::getSlot(const Value *V) const {
+unsigned SlotCalculator::getSlot(const Value *V) const {
std::map<const Value*, unsigned>::const_iterator I = NodeMap.find(V);
- if (I != NodeMap.end())
- return (int)I->second;
-
- return -1;
+ assert(I != NodeMap.end() && "Value not in slotcalculator!");
+ return (int)I->second;
}
int SlotCalculator::getTypeSlot(const Type*T) const {
std::map<const Type*, unsigned>::const_iterator I = TypeMap.find(T);
- if (I != TypeMap.end())
- return (int)I->second;
-
- return -1;
+ assert(I != TypeMap.end() && "Type not in slotcalc!");
+ return (int)I->second;
}
void SlotCalculator::CreateSlotIfNeeded(const Value *V) {
// Check to see if it's already in!
- if (getSlot(V) != -1) return;
+ if (NodeMap.count(V)) return;
const Type *Ty = V->getType();
assert(Ty != Type::VoidTy && "Can't insert void values!");
@@ -351,8 +347,8 @@ void SlotCalculator::CreateSlotIfNeeded(const Value *V) {
unsigned SlotCalculator::getOrCreateTypeSlot(const Type *Ty) {
- int SlotNo = getTypeSlot(Ty); // Check to see if it's already in!
- if (SlotNo != -1) return (unsigned)SlotNo;
+ std::map<const Type*, unsigned>::iterator TyIt = TypeMap.find(Ty);
+ if (TyIt != TypeMap.end()) return TyIt->second;
// Insert into TypeMap.
unsigned ResultSlot = TypeMap[Ty] = Types.size();