[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Verifier.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Feb 24 08:58:45 PST 2005



Changes in directory llvm/lib/VMCore:

AsmWriter.cpp updated: 1.170 -> 1.171
Verifier.cpp updated: 1.125 -> 1.126
---
Log message:

Fix some problems where the verifier would crash on invalid input instead of
reporting the problem and exiting.


---
Diffs of the changes:  (+7 -3)

 AsmWriter.cpp |    9 ++++++---
 Verifier.cpp  |    1 +
 2 files changed, 7 insertions(+), 3 deletions(-)


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.170 llvm/lib/VMCore/AsmWriter.cpp:1.171
--- llvm/lib/VMCore/AsmWriter.cpp:1.170	Wed Feb  9 11:45:03 2005
+++ llvm/lib/VMCore/AsmWriter.cpp	Thu Feb 24 10:58:29 2005
@@ -755,9 +755,12 @@
 
 void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, 
                                   bool PrintName) {
-  assert(Operand != 0 && "Illegal Operand");
-  if (PrintType) { Out << ' '; printType(Operand->getType()); }
-  WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
+  if (Operand != 0) {
+    if (PrintType) { Out << ' '; printType(Operand->getType()); }
+    WriteAsOperandInternal(Out, Operand, PrintName, TypeNames, &Machine);
+  } else {
+    Out << "<null operand!>";
+  }
 }
 
 


Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.125 llvm/lib/VMCore/Verifier.cpp:1.126
--- llvm/lib/VMCore/Verifier.cpp:1.125	Sat Jan 22 11:36:16 2005
+++ llvm/lib/VMCore/Verifier.cpp	Thu Feb 24 10:58:29 2005
@@ -592,6 +592,7 @@
   for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
     // Check to make sure that the "address of" an intrinsic function is never
     // taken.
+    Assert1(I.getOperand(i) != 0, "Instruction has null operand!", &I);
     if (Function *F = dyn_cast<Function>(I.getOperand(i))) {
       Assert1(!F->isIntrinsic() || (i == 0 && isa<CallInst>(I)),
               "Cannot take the address of an intrinsic!", &I);






More information about the llvm-commits mailing list