Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.242 -> 1.243 --- Log message: Back out the last patch which is a nightly test killer. The assertion in getLocalSlot fires on many, many values. It broke nearly all of the dejagnu tests. Simple changes to the assertion did not fix the problem. --- Diffs of the changes: (+63 -63) AsmWriter.cpp | 126 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 63 insertions(+), 63 deletions(-) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.242 llvm/lib/VMCore/AsmWriter.cpp:1.243 --- llvm/lib/VMCore/AsmWriter.cpp:1.242 Wed Jan 10 01:01:46 2007 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Jan 10 03:18:16 2007 @@ -75,9 +75,9 @@ /// @{ public: /// Return the slot number of the specified value in it's type - /// plane. If something is not in the SlotMachine, return -1. - int getLocalSlot(const Value *V); - int getGlobalSlot(const GlobalValue *V); + /// plane. Its an error to ask for something not in the SlotMachine. + /// Its an error to ask for a Type* + int getSlot(const Value *V); /// @} /// @name Mutators @@ -597,20 +597,13 @@ } else { int Slot; if (Machine) { - if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) - Slot = Machine->getGlobalSlot(GV); - else - Slot = Machine->getLocalSlot(V); + Slot = Machine->getSlot(V); } else { Machine = createSlotMachine(V); - if (Machine) { - if (const GlobalValue *GV = dyn_cast<GlobalValue>(V)) - Slot = Machine->getGlobalSlot(GV); - else - Slot = Machine->getLocalSlot(V); - } else { + if (Machine) + Slot = Machine->getSlot(V); + else Slot = -1; - } delete Machine; } if (Slot != -1) @@ -1049,7 +1042,7 @@ Out << "\n" << getLLVMName(BB->getName(), false) << ':'; } else if (!BB->use_empty()) { // Don't print block # of no uses... Out << "\n; <label>:"; - int Slot = Machine.getLocalSlot(BB); + int Slot = Machine.getSlot(BB); if (Slot != -1) Out << Slot; else @@ -1098,7 +1091,7 @@ printType(V.getType()) << '>'; if (!V.hasName()) { - int SlotNum = Machine.getLocalSlot(&V); + int SlotNum = Machine.getSlot(&V); if (SlotNum == -1) Out << ":<badref>"; else @@ -1412,7 +1405,7 @@ { } -inline void SlotMachine::initialize() { +inline void SlotMachine::initialize(void) { if (TheModule) { processModule(); TheModule = 0; ///< Prevent re-processing next time we're called. @@ -1470,7 +1463,7 @@ } /// Clean up after incorporating a function. This is the only way to get out of -/// the function incorporation state that affects get*Slot/Create*Slot. Function +/// the function incorporation state that affects getSlot/Create*Slot. Function /// incorporation state is indicated by TheFunction != 0. void SlotMachine::purgeFunction() { SC_DEBUG("begin purgeFunction!\n"); @@ -1480,57 +1473,64 @@ SC_DEBUG("end purgeFunction!\n"); } -/// getGlobalSlot - Get the slot number of a global value. -int SlotMachine::getGlobalSlot(const GlobalValue *V) { - // Check for uninitialized state and do lazy initialization. - initialize(); - - // Find the type plane in the module map - TypedPlanes::const_iterator MI = mMap.find(V->getType()); - if (MI == mMap.end()) return -1; - - // Lookup the value in the module plane's map. - ValueMap::const_iterator MVI = MI->second.map.find(V); - return MVI != MI->second.map.end() ? MVI->second : -1; -} - - -/// getLocalSlot - Get the slot number for a value that is local to a function. -int SlotMachine::getLocalSlot(const Value *V) { - assert(!isa<Constant>(V) && "Can't get a constant or global slot with this!"); +/// Get the slot number for a value. This function will assert if you +/// ask for a Value that hasn't previously been inserted with Create*Slot. +int SlotMachine::getSlot(const Value *V) { + assert(V && "Can't get slot for null Value"); + assert(!isa<Constant>(V) || isa<GlobalValue>(V) && + "Can't insert a non-GlobalValue Constant into SlotMachine"); - // Check for uninitialized state and do lazy initialization. - initialize(); + // Check for uninitialized state and do lazy initialization + this->initialize(); // Get the type of the value - const Type *VTy = V->getType(); + const Type* VTy = V->getType(); - TypedPlanes::const_iterator FI = fMap.find(VTy); - if (FI == fMap.end()) return -1; - - // Lookup the Value in the function and module maps. - ValueMap::const_iterator FVI = FI->second.map.find(V); + // Find the type plane in the module map TypedPlanes::const_iterator MI = mMap.find(VTy); - - // If the value doesn't exist in the function map - if (FVI == FI->second.map.end()) { - // Look up the value in the module map. - if (MI == mMap.end()) return -1; - ValueMap::const_iterator MVI = MI->second.map.find(V); - // If we didn't find it, it wasn't inserted - if (MVI == MI->second.map.end()) return -1; - assert(MVI != MI->second.map.end() && "Value not found"); - // We found it only at the module level - return MVI->second; + + if (TheFunction) { + // Lookup the type in the function map too + TypedPlanes::const_iterator FI = fMap.find(VTy); + // If there is a corresponding type plane in the function map + if (FI != fMap.end()) { + // Lookup the Value in the function map + ValueMap::const_iterator FVI = FI->second.map.find(V); + // If the value doesn't exist in the function map + if (FVI == FI->second.map.end()) { + // Look up the value in the module map. + if (MI == mMap.end()) return -1; + ValueMap::const_iterator MVI = MI->second.map.find(V); + // If we didn't find it, it wasn't inserted + if (MVI == MI->second.map.end()) return -1; + assert(MVI != MI->second.map.end() && "Value not found"); + // We found it only at the module level + return MVI->second; + + // else the value exists in the function map + } else { + // Return the slot number as the module's contribution to + // the type plane plus the index in the function's contribution + // to the type plane. + if (MI != mMap.end()) + return MI->second.next_slot + FVI->second; + else + return FVI->second; + } + } } - - // Return the slot number as the module's contribution to - // the type plane plus the index in the function's contribution - // to the type plane. - if (MI != mMap.end()) - return MI->second.next_slot + FVI->second; - else - return FVI->second; + + // N.B. Can get here only if either !TheFunction or the function doesn't + // have a corresponding type plane for the Value + + // Make sure the type plane exists + if (MI == mMap.end()) return -1; + // Lookup the value in the module's map + ValueMap::const_iterator MVI = MI->second.map.find(V); + // Make sure we found it. + if (MVI == MI->second.map.end()) return -1; + // Return it. + return MVI->second; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits