mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
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
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user