diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-16 18:13:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-16 18:13:05 +0000 |
commit | 30483b0c8473dbdc0a09ae8a44034200799d67ec (patch) | |
tree | 4a40756ab34bc53be5b5e1a9d60038529c73977c | |
parent | a9d12c0a56e60a331af3ef6209d754f0c12e8bab (diff) |
Teach the X86 backend about unreachable and undef. Among other things, we
now compile:
'foo() {}' into "ret" instead of "mov EAX, 0; ret"
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17049 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/X86ISelSimple.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index a938bae3fc..926492e31f 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -175,6 +175,7 @@ namespace { // Control flow operators void visitReturnInst(ReturnInst &RI); void visitBranchInst(BranchInst &BI); + void visitUnreachableInst(UnreachableInst &UI) {} struct ValueRecord { Value *Val; @@ -447,7 +448,20 @@ unsigned X86ISel::getFixedSizedAllocaFI(AllocaInst *AI) { 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: |