Fix really nasty bugs in the CWriter, handling invoke instructions. Tracking
authorChris Lattner <sabre@nondot.org>
Thu, 28 Aug 2003 19:56:10 +0000 (19:56 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 28 Aug 2003 19:56:10 +0000 (19:56 +0000)
these down was NOT phun.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8181 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index a62207514150334776258ae08a6c09d87a94954c..721ead091c2916eaaf26891c5fe8fd01b6fa7f75 100644 (file)
@@ -894,7 +894,8 @@ void CWriter::printFunction(Function *F) {
          UI != UE; ++UI)
       if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*UI))
         if (TI != Prev->getTerminator() ||
-            isa<SwitchInst>(Prev->getTerminator())) {
+            isa<SwitchInst>(Prev->getTerminator()) ||
+            isa<InvokeInst>(Prev->getTerminator())) {
           NeedsLabel = true;
           break;        
         }
@@ -968,6 +969,8 @@ void CWriter::visitInvokeInst(InvokeInst &II) {
   Out << "    }\n"
       << "    __llvm_jmpbuf_list = &Entry;\n"
       << "    ";
+
+  if (II.getType() != Type::VoidTy) outputLValue(&II);
   visitCallSite(&II);
   Out << ";\n"
       << "    __llvm_jmpbuf_list = Entry.next;\n"
@@ -998,7 +1001,7 @@ void CWriter::printBranchToBlock(BasicBlock *CurBB, BasicBlock *Succ,
     Out << ";   /* for PHI node */\n";
   }
 
-  if (CurBB->getNext() != Succ) {
+  if (CurBB->getNext() != Succ || isa<InvokeInst>(CurBB->getTerminator())) {
     Out << std::string(Indent, ' ') << "  goto ";
     writeOperand(Succ);
     Out << ";\n";
index a62207514150334776258ae08a6c09d87a94954c..721ead091c2916eaaf26891c5fe8fd01b6fa7f75 100644 (file)
@@ -894,7 +894,8 @@ void CWriter::printFunction(Function *F) {
          UI != UE; ++UI)
       if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*UI))
         if (TI != Prev->getTerminator() ||
-            isa<SwitchInst>(Prev->getTerminator())) {
+            isa<SwitchInst>(Prev->getTerminator()) ||
+            isa<InvokeInst>(Prev->getTerminator())) {
           NeedsLabel = true;
           break;        
         }
@@ -968,6 +969,8 @@ void CWriter::visitInvokeInst(InvokeInst &II) {
   Out << "    }\n"
       << "    __llvm_jmpbuf_list = &Entry;\n"
       << "    ";
+
+  if (II.getType() != Type::VoidTy) outputLValue(&II);
   visitCallSite(&II);
   Out << ";\n"
       << "    __llvm_jmpbuf_list = Entry.next;\n"
@@ -998,7 +1001,7 @@ void CWriter::printBranchToBlock(BasicBlock *CurBB, BasicBlock *Succ,
     Out << ";   /* for PHI node */\n";
   }
 
-  if (CurBB->getNext() != Succ) {
+  if (CurBB->getNext() != Succ || isa<InvokeInst>(CurBB->getTerminator())) {
     Out << std::string(Indent, ' ') << "  goto ";
     writeOperand(Succ);
     Out << ";\n";