[pr19635] Revert most of r170537, and add new testcase.

Patch provided by Andrey Kuharev.

Sorry, r170537 was obviously wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215190 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Patrik Hagglund 2014-08-08 08:21:19 +00:00
parent 8e5c298a17
commit cf403861a3
5 changed files with 14 additions and 7 deletions

View File

@ -2329,9 +2329,9 @@ public:
/// all the time, e.g. i1 on x86-64. It is also not necessary for non-C
/// calling conventions. The frontend should handle this and include all of
/// the necessary information.
virtual MVT getTypeForExtArgOrReturn(MVT VT,
virtual EVT getTypeForExtArgOrReturn(LLVMContext &Context, EVT VT,
ISD::NodeType /*ExtendKind*/) const {
MVT MinVT = getRegisterType(MVT::i32);
EVT MinVT = getRegisterType(Context, MVT::i32);
return VT.bitsLT(MinVT) ? MinVT : VT;
}

View File

@ -1244,7 +1244,7 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) {
ExtendKind = ISD::ZERO_EXTEND;
if (ExtendKind != ISD::ANY_EXTEND && VT.isInteger())
VT = TLI->getTypeForExtArgOrReturn(VT.getSimpleVT(), ExtendKind);
VT = TLI->getTypeForExtArgOrReturn(*DAG.getContext(), VT, ExtendKind);
unsigned NumParts = TLI->getNumRegisters(*DAG.getContext(), VT);
MVT PartVT = TLI->getRegisterType(*DAG.getContext(), VT);

View File

@ -2062,8 +2062,8 @@ bool X86TargetLowering::isUsedByReturnOnly(SDNode *N, SDValue &Chain) const {
return true;
}
MVT
X86TargetLowering::getTypeForExtArgOrReturn(MVT VT,
EVT
X86TargetLowering::getTypeForExtArgOrReturn(LLVMContext &Context, EVT VT,
ISD::NodeType ExtendKind) const {
MVT ReturnMVT;
// TODO: Is this also valid on 32-bit?
@ -2072,7 +2072,7 @@ X86TargetLowering::getTypeForExtArgOrReturn(MVT VT,
else
ReturnMVT = MVT::i32;
MVT MinVT = getRegisterType(ReturnMVT);
EVT MinVT = getRegisterType(Context, ReturnMVT);
return VT.bitsLT(MinVT) ? MinVT : VT;
}

View File

@ -940,7 +940,7 @@ namespace llvm {
bool mayBeEmittedAsTailCall(CallInst *CI) const override;
MVT getTypeForExtArgOrReturn(MVT VT,
EVT getTypeForExtArgOrReturn(LLVMContext &Context, EVT VT,
ISD::NodeType ExtendKind) const override;
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,

View File

@ -0,0 +1,7 @@
; RUN: llc -mtriple=i386-pc-win32 < %s | FileCheck %s
; Check that the testcase does not crash
define zeroext i2 @crash () {
ret i2 0
}
; CHECK: xorl %eax, %eax
; CHECK-NEXT: retl