[llvm-commits] [llvm] r55819 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp
Dan Gohman
gohman at apple.com
Thu Sep 4 18:15:35 PDT 2008
Author: djg
Date: Thu Sep 4 20:15:35 2008
New Revision: 55819
URL: http://llvm.org/viewvc/llvm-project?rev=55819&view=rev
Log:
Fix X86FastISel code for comparisons and conditional branches
to check the result of getRegForValue before using it, and
to check for illegal operand types.
Modified:
llvm/trunk/lib/Target/X86/X86FastISel.cpp
Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=55819&r1=55818&r2=55819&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Sep 4 20:15:35 2008
@@ -263,10 +263,16 @@
CmpInst *CI = cast<CmpInst>(I);
unsigned Op0Reg = getRegForValue(CI->getOperand(0));
+ if (Op0Reg == 0) return false;
unsigned Op1Reg = getRegForValue(CI->getOperand(1));
+ if (Op1Reg == 0) return false;
+
+ MVT VT = TLI.getValueType(I->getOperand(0)->getType());
+ if (!TLI.isTypeLegal(VT))
+ return false;
unsigned Opc;
- switch (TLI.getValueType(I->getOperand(0)->getType()).getSimpleVT()) {
+ switch (VT.getSimpleVT()) {
case MVT::i8: Opc = X86::CMP8rr; break;
case MVT::i16: Opc = X86::CMP16rr; break;
case MVT::i32: Opc = X86::CMP32rr; break;
@@ -398,6 +404,7 @@
if (I->getType() == Type::Int8Ty &&
I->getOperand(0)->getType() == Type::Int1Ty) {
unsigned ResultReg = getRegForValue(I->getOperand(0));
+ if (ResultReg == 0) return false;
UpdateValueMap(I, ResultReg);
return true;
}
@@ -409,6 +416,7 @@
BranchInst *BI = cast<BranchInst>(I);
// Unconditional branches are selected by tablegen-generated code.
unsigned OpReg = getRegForValue(BI->getCondition());
+ if (OpReg == 0) return false;
MachineBasicBlock *TrueMBB = MBBMap[BI->getSuccessor(0)];
MachineBasicBlock *FalseMBB = MBBMap[BI->getSuccessor(1)];
More information about the llvm-commits
mailing list