[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jun 9 14:47:02 PDT 2004
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.137 -> 1.138
---
Log message:
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.
---
Diffs of the changes: (+23 -16)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.137 llvm/lib/VMCore/AsmWriter.cpp:1.138
--- llvm/lib/VMCore/AsmWriter.cpp:1.137 Wed Jun 9 10:26:53 2004
+++ llvm/lib/VMCore/AsmWriter.cpp Wed Jun 9 14:41:19 2004
@@ -74,7 +74,7 @@
/// 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 @@
}
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 @@
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 @@
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 @@
/// 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 @@
// 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 @@
// 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;
}
More information about the llvm-commits
mailing list