From 7a2c00370de861c3c9812b70d220edfe35c69410 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 13 Apr 2017 15:00:18 +0000 Subject: [PATCH 1/2] [Hexagon] Fix "LowerFormalArguments emitted a value with the wrong type!" assertion Patch by Michael Wu. Differential Revision: https://reviews.llvm.org/D31999 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300198 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Hexagon/HexagonISelLowering.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Target/Hexagon/HexagonISelLowering.cpp b/lib/Target/Hexagon/HexagonISelLowering.cpp index be70e1464e55..a8b74f62a696 100644 --- a/lib/Target/Hexagon/HexagonISelLowering.cpp +++ b/lib/Target/Hexagon/HexagonISelLowering.cpp @@ -1234,7 +1234,7 @@ SDValue HexagonTargetLowering::LowerFormalArguments( InVals.push_back(FIN); } else { InVals.push_back( - DAG.getLoad(VA.getLocVT(), dl, Chain, FIN, MachinePointerInfo())); + DAG.getLoad(VA.getValVT(), dl, Chain, FIN, MachinePointerInfo())); } } } From 9394f968c8289c08e747293aa08f10dbcd8b7828 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Thu, 13 Apr 2017 15:05:51 +0000 Subject: [PATCH 2/2] [Hexagon] Implement HexagonTargetLowering::CanLowerReturn Patch by Michael Wu. Differential Revision: https://reviews.llvm.org/D32000 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300199 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Hexagon/HexagonISelLowering.cpp | 25 +++++++++++----------- lib/Target/Hexagon/HexagonISelLowering.h | 5 +++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/Target/Hexagon/HexagonISelLowering.cpp b/lib/Target/Hexagon/HexagonISelLowering.cpp index a8b74f62a696..0e8f21b44f73 100644 --- a/lib/Target/Hexagon/HexagonISelLowering.cpp +++ b/lib/Target/Hexagon/HexagonISelLowering.cpp @@ -485,9 +485,7 @@ static bool RetCC_Hexagon32(unsigned ValNo, MVT ValVT, } } - unsigned Offset = State.AllocateStack(4, 4); - State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); - return false; + return true; } static bool RetCC_Hexagon64(unsigned ValNo, MVT ValVT, @@ -500,9 +498,7 @@ static bool RetCC_Hexagon64(unsigned ValNo, MVT ValVT, } } - unsigned Offset = State.AllocateStack(8, 8); - State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); - return false; + return true; } static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT, @@ -513,7 +509,6 @@ static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT, bool UseHVX = HST.useHVXOps(); bool UseHVXDbl = HST.useHVXDblOps(); - unsigned OffSiz = 64; if (LocVT == MVT::v16i32) { if (unsigned Reg = State.AllocateReg(Hexagon::V0)) { State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); @@ -525,18 +520,14 @@ static bool RetCC_HexagonVector(unsigned ValNo, MVT ValVT, State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); return false; } - OffSiz = 128; } else if (LocVT == MVT::v64i32) { if (unsigned Reg = State.AllocateReg(Hexagon::W0)) { State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo)); return false; } - OffSiz = 256; } - unsigned Offset = State.AllocateStack(OffSiz, OffSiz); - State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo)); - return false; + return true; } void HexagonTargetLowering::promoteLdStType(MVT VT, MVT PromotedLdStVT) { @@ -592,6 +583,16 @@ static bool isHvxVectorType(MVT Ty) { } } +bool +HexagonTargetLowering::CanLowerReturn( + CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, + const SmallVectorImpl &Outs, + LLVMContext &Context) const { + SmallVector RVLocs; + CCState CCInfo(CallConv, isVarArg, MF, RVLocs, Context); + return CCInfo.CheckReturn(Outs, RetCC_Hexagon); +} + // LowerReturn - Lower ISD::RET. If a struct is larger than 8 bytes and is // passed by value, the function prototype is modified to return void and // the value is stored in memory pointed by a pointer passed by caller. diff --git a/lib/Target/Hexagon/HexagonISelLowering.h b/lib/Target/Hexagon/HexagonISelLowering.h index a8ed29e585d4..0b6b25ecd1c4 100644 --- a/lib/Target/Hexagon/HexagonISelLowering.h +++ b/lib/Target/Hexagon/HexagonISelLowering.h @@ -185,6 +185,11 @@ namespace HexagonISD { SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const; SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const; + bool CanLowerReturn(CallingConv::ID CallConv, + MachineFunction &MF, bool isVarArg, + const SmallVectorImpl &Outs, + LLVMContext &Context) const override; + SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl &Outs, const SmallVectorImpl &OutVals,