diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 263385c6119..f7e1f051f7e 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -75,9 +75,9 @@ public: /// @{ public: /// Return the slot number of the specified value in it's type - /// 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); + /// plane. If something is not in the SlotMachine, return -1. + int getLocalSlot(const Value *V); + int getGlobalSlot(const GlobalValue *V); /// @} /// @name Mutators @@ -597,13 +597,20 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V, } else { int Slot; if (Machine) { - Slot = Machine->getSlot(V); + if (const GlobalValue *GV = dyn_cast(V)) + Slot = Machine->getGlobalSlot(GV); + else + Slot = Machine->getLocalSlot(V); } else { Machine = createSlotMachine(V); - if (Machine) - Slot = Machine->getSlot(V); - else + if (Machine) { + if (const GlobalValue *GV = dyn_cast(V)) + Slot = Machine->getGlobalSlot(GV); + else + Slot = Machine->getLocalSlot(V); + } else { Slot = -1; + } delete Machine; } if (Slot != -1) @@ -1042,7 +1049,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { Out << "\n" << getLLVMName(BB->getName(), false) << ':'; } else if (!BB->use_empty()) { // Don't print block # of no uses... Out << "\n;