diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-12 07:51:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-12 07:51:14 +0000 |
commit | ce6bcf0847329c708a09e1dba8adfb7fd92c4beb (patch) | |
tree | 7f45f321a998c65107748aaaa832b4fece2baa36 /llvm/lib/Target/X86/X86FastISel.cpp | |
parent | a101f6f8d38b798a3d7c102dab1d39280ec49b6e (diff) | |
download | bcm5719-llvm-ce6bcf0847329c708a09e1dba8adfb7fd92c4beb.tar.gz bcm5719-llvm-ce6bcf0847329c708a09e1dba8adfb7fd92c4beb.zip |
fix a cross-block fastisel crash handling overflow intrinsics.
See comment for details. This fixes rdar://6772169
llvm-svn: 68890
Diffstat (limited to 'llvm/lib/Target/X86/X86FastISel.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86FastISel.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp index c2932ff79e5..2cfa719d73b 100644 --- a/llvm/lib/Target/X86/X86FastISel.cpp +++ b/llvm/lib/Target/X86/X86FastISel.cpp @@ -809,8 +809,8 @@ bool X86FastISel::X86SelectBranch(Instruction *I) { unsigned OpCode = SetMI->getOpcode(); if (OpCode == X86::SETOr || OpCode == X86::SETBr) { - BuildMI(MBB, DL, TII.get((OpCode == X86::SETOr) ? - X86::JO : X86::JB)).addMBB(TrueMBB); + BuildMI(MBB, DL, TII.get(OpCode == X86::SETOr ? X86::JO : X86::JB)) + .addMBB(TrueMBB); FastEmitBranch(FalseMBB); MBB->addSuccessor(TrueMBB); return true; @@ -1072,9 +1072,20 @@ bool X86FastISel::X86VisitIntrinsicCall(IntrinsicInst &I) { unsigned ResultReg = createResultReg(TLI.getRegClassFor(VT)); BuildMI(MBB, DL, TII.get(OpC), ResultReg).addReg(Reg1).addReg(Reg2); - UpdateValueMap(&I, ResultReg); - - ResultReg = createResultReg(TLI.getRegClassFor(MVT::i8)); + unsigned DestReg1 = UpdateValueMap(&I, ResultReg); + + // If the add with overflow is an intra-block value then we just want to + // create temporaries for it like normal. If it is a cross-block value then + // UpdateValueMap will return the cross-block register used. Since we + // *really* want the value to be live in the register pair known by + // UpdateValueMap, we have to use DestReg1+1 as the destination register in + // the cross block case. In the non-cross-block case, we should just make + // another register for the value. + if (DestReg1 != ResultReg) + ResultReg = DestReg1+1; + else + ResultReg = createResultReg(TLI.getRegClassFor(MVT::i8)); + unsigned Opc = X86::SETBr; if (I.getIntrinsicID() == Intrinsic::sadd_with_overflow) Opc = X86::SETOr; |