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

Chris Lattner lattner at cs.uiuc.edu
Sun Oct 17 10:49:13 PDT 2004



Changes in directory llvm/lib/Target/CBackend:

Writer.cpp updated: 1.202 -> 1.203
---
Log message:

The first hunk corrects a bug when printing undef null values.  We would print
0->field, which is illegal.  Now we print ((foo*)0)->field.

The second hunk is an optimization to not print undefined phi values.


---
Diffs of the changes:  (+11 -6)

Index: llvm/lib/Target/CBackend/Writer.cpp
diff -u llvm/lib/Target/CBackend/Writer.cpp:1.202 llvm/lib/Target/CBackend/Writer.cpp:1.203
--- llvm/lib/Target/CBackend/Writer.cpp:1.202	Sat Oct 16 13:12:13 2004
+++ llvm/lib/Target/CBackend/Writer.cpp	Sun Oct 17 12:48:59 2004
@@ -523,7 +523,9 @@
       abort();
     }
   } else if (isa<UndefValue>(CPV) && CPV->getType()->isFirstClassType()) {
-    Out << "0";
+    Out << "((";
+    printType(Out, CPV->getType());
+    Out << ")/*UNDEF*/0)";
     return;
   }
 
@@ -1234,11 +1236,14 @@
        SI != E; ++SI)
     for (BasicBlock::iterator I = SI->begin(); isa<PHINode>(I); ++I) {
       PHINode *PN = cast<PHINode>(I);
-      //  now we have to do the printing
-      Out << std::string(Indent, ' ');
-      Out << "  " << Mang->getValueName(I) << "__PHI_TEMPORARY = ";
-      writeOperand(PN->getIncomingValue(PN->getBasicBlockIndex(CurBlock)));
-      Out << ";   /* for PHI node */\n";
+      // Now we have to do the printing.
+      Value *IV = PN->getIncomingValueForBlock(CurBlock);
+      if (!isa<UndefValue>(IV)) {
+        Out << std::string(Indent, ' ');
+        Out << "  " << Mang->getValueName(I) << "__PHI_TEMPORARY = ";
+        writeOperand(IV);
+        Out << ";   /* for PHI node */\n";
+      }
     }
 }
 






More information about the llvm-commits mailing list