[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Apr 23 14:16:02 PDT 2003


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.80 -> 1.81

---
Log message:

Fix problem where labels were being incorrectly elided, and fix problem
where PHI copies where not emitted for the default label of switch insts


---
Diffs of the changes:

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.80 llvm/lib/CWriter/Writer.cpp:1.81
--- llvm/lib/CWriter/Writer.cpp:1.80	Wed Apr 23 14:09:22 2003
+++ llvm/lib/CWriter/Writer.cpp	Wed Apr 23 14:15:13 2003
@@ -817,7 +817,8 @@
     for (Value::use_iterator UI = BB->use_begin(), UE = BB->use_end();
          UI != UE; ++UI)
       if (TerminatorInst *TI = dyn_cast<TerminatorInst>(*UI))
-        if (TI != Prev->getTerminator()) {
+        if (TI != Prev->getTerminator() ||
+            isa<SwitchInst>(Prev->getTerminator())) {
           NeedsLabel = true;
           break;        
         }
@@ -867,8 +868,8 @@
 void CWriter::visitSwitchInst(SwitchInst &SI) {
   Out << "  switch (";
   writeOperand(SI.getOperand(0));
-  Out << ") {\n  default: goto ";
-  writeOperand(SI.getDefaultDest());
+  Out << ") {\n  default:\n";
+  printBranchToBlock(SI.getParent(), SI.getDefaultDest(), 2);
   Out << ";\n";
   for (unsigned i = 2, e = SI.getNumOperands(); i != e; i += 2) {
     Out << "  case ";





More information about the llvm-commits mailing list