[llvm-commits] CVS: llvm/lib/Target/X86/X86ISelSimple.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Oct 16 11:13:16 PDT 2004



Changes in directory llvm/lib/Target/X86:

X86ISelSimple.cpp updated: 1.287 -> 1.288
---
Log message:

Teach the X86 backend about unreachable and undef.  Among other things, we
now compile:

'foo() {}' into "ret" instead of "mov EAX, 0; ret"





---
Diffs of the changes:  (+15 -1)

Index: llvm/lib/Target/X86/X86ISelSimple.cpp
diff -u llvm/lib/Target/X86/X86ISelSimple.cpp:1.287 llvm/lib/Target/X86/X86ISelSimple.cpp:1.288
--- llvm/lib/Target/X86/X86ISelSimple.cpp:1.287	Fri Oct 15 00:05:29 2004
+++ llvm/lib/Target/X86/X86ISelSimple.cpp	Sat Oct 16 13:13:05 2004
@@ -175,6 +175,7 @@
     // Control flow operators
     void visitReturnInst(ReturnInst &RI);
     void visitBranchInst(BranchInst &BI);
+    void visitUnreachableInst(UnreachableInst &UI) {}
 
     struct ValueRecord {
       Value *Val;
@@ -447,7 +448,20 @@
 void X86ISel::copyConstantToRegister(MachineBasicBlock *MBB,
                                      MachineBasicBlock::iterator IP,
                                      Constant *C, unsigned R) {
-  if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
+  if (isa<UndefValue>(C)) {
+    switch (getClassB(C->getType())) {
+    case cFP:
+      // FIXME: SHOULD TEACH STACKIFIER ABOUT UNDEF VALUES!
+      BuildMI(*MBB, IP, X86::FLD0, 0, R);
+      return;
+    case cLong:
+      BuildMI(*MBB, IP, X86::IMPLICIT_DEF, 0, R+1);
+      // FALL THROUGH
+    default:
+      BuildMI(*MBB, IP, X86::IMPLICIT_DEF, 0, R);
+      return;
+    }
+  } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
     unsigned Class = 0;
     switch (CE->getOpcode()) {
     case Instruction::GetElementPtr:






More information about the llvm-commits mailing list