aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/AsmWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-09 19:41:19 +0000
committerChris Lattner <sabre@nondot.org>2004-06-09 19:41:19 +0000
commit69566459cc27c5210472a87ae2fe7b2ca64f9fc8 (patch)
tree7cdeb096ac89d789bf73eb1c3b66f30a9b8236bf /lib/VMCore/AsmWriter.cpp
parent389174b098e4d106729d64bd782a29c4af20ad86 (diff)
downloadexternal_llvm-69566459cc27c5210472a87ae2fe7b2ca64f9fc8.zip
external_llvm-69566459cc27c5210472a87ae2fe7b2ca64f9fc8.tar.gz
external_llvm-69566459cc27c5210472a87ae2fe7b2ca64f9fc8.tar.bz2
Make the asmwriter much more tolerant of errors (which are common when working
on new front-ends and stuff). Also get rid of some tabs that snuck in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14100 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/AsmWriter.cpp')
-rw-r--r--lib/VMCore/AsmWriter.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 24c3348..72caa80 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -74,7 +74,7 @@ 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*
- unsigned getSlot(const Value *V, bool ignoreMissing = false ) ;
+ int getSlot(const Value *V);
/// Determine if a Value has a slot or not
bool hasSlot(const Value* V);
@@ -525,12 +525,16 @@ static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
}
Machine = createSlotMachine(V);
- if (Machine == 0) { Out << "BAD VALUE TYPE!"; return; }
-
- Slot = Machine->getSlot(V);
+ if (Machine == 0)
+ Slot = Machine->getSlot(V);
+ else
+ Slot = -1;
delete Machine;
}
- Out << '%' << Slot;
+ if (Slot != -1)
+ Out << '%' << Slot;
+ else
+ Out << "<badref>";
}
}
}
@@ -841,7 +845,12 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
if (BB->hasName()) { // Print out the label if it exists...
*Out << "\n" << BB->getName() << ':';
} else if (!BB->use_empty()) { // Don't print block # of no uses...
- *Out << "\n; <label>:" << Machine.getSlot(BB);
+ *Out << "\n; <label>:";
+ int Slot = Machine.getSlot(BB);
+ if (Slot != -1)
+ *Out << Slot;
+ else
+ *Out << "<badref>";
}
if (BB->getParent() == 0)
@@ -886,11 +895,11 @@ void AssemblyWriter::printInfoComment(const Value &V) {
printType(V.getType()) << '>';
if (!V.hasName()) {
- unsigned SlotNum = Machine.getSlot(&V,true);
- if ( unsigned(-1) == SlotNum )
- *Out << ":??";
+ int SlotNum = Machine.getSlot(&V);
+ if (SlotNum == -1)
+ *Out << ":<badref>";
else
- *Out << ':' << SlotNum; // Print out the def slot taken.
+ *Out << ':' << SlotNum; // Print out the def slot taken.
}
*Out << " [#uses=" << V.use_size() << ']'; // Output # uses
}
@@ -1273,7 +1282,7 @@ void SlotMachine::purgeFunction() {
/// Get the slot number for a value. This function will assert if you
/// ask for a Value that hasn't previously been inserted with createSlot.
/// Types are forbidden because Type does not inherit from Value (any more).
-unsigned SlotMachine::getSlot(const Value *V, bool ignoreMissing ) {
+int SlotMachine::getSlot(const Value *V) {
assert( V && "Can't get slot for null Value" );
assert( !isa<Type>(V) && "Can't get slot for a type" );
assert(!isa<Constant>(V) || isa<GlobalValue>(V) &&
@@ -1304,7 +1313,7 @@ unsigned SlotMachine::getSlot(const Value *V, bool ignoreMissing ) {
// Look up the value in the module map
ValueMap::const_iterator MVI = MI->second.map.find(V);
// If we didn't find it, it wasn't inserted
- if ( ignoreMissing && MVI == MI->second.map.end()) return unsigned(-1);
+ 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;
@@ -1323,13 +1332,11 @@ unsigned SlotMachine::getSlot(const Value *V, bool ignoreMissing ) {
// have a corresponding type plane for the Value
// Make sure the type plane exists
- if ( ignoreMissing && MI == mMap.end()) return unsigned(-1);
- assert( MI != mMap.end() && "No such type plane!" );
+ 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 ( ignoreMissing && MVI == MI->second.map.end()) return unsigned(-1);
- assert( MVI != MI->second.map.end() && "Value not found" );
+ if (MVI == MI->second.map.end()) return -1;
// Return it.
return MVI->second;
}