From 22379bc7bb28fbfb1182877e6dc316aaab98a4ba Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 11 Jan 2007 03:54:27 +0000 Subject: [PATCH] Recommit my previous patch with a bugfix: printInfoComment works on both local and global values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33068 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 130 ++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 63 deletions(-) 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;