From b027fa001f16660a231a54ecea6a79f5c7855d7c Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Mon, 31 Dec 2007 18:35:50 +0000 Subject: Fix PR1833 - eh.exception and eh.selector return two values, which means doing extra legalization work. It would be easier to get this kind of thing right if there was some documentation... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45472 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index e1540ea1d2..688e4f9fea 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -858,7 +858,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { default: assert(0 && "This action is not supported yet!"); case TargetLowering::Expand: { unsigned Reg = TLI.getExceptionAddressRegister(); - Result = DAG.getCopyFromReg(Tmp1, Reg, VT).getValue(Op.ResNo); + Result = DAG.getCopyFromReg(Tmp1, Reg, VT); } break; case TargetLowering::Custom: @@ -868,12 +868,23 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { case TargetLowering::Legal: { SDOperand Ops[] = { DAG.getConstant(0, VT), Tmp1 }; Result = DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(VT, MVT::Other), - Ops, 2).getValue(Op.ResNo); + Ops, 2); break; } } } - break; + if (Result.Val->getNumValues() == 1) break; + + assert(Result.Val->getNumValues() == 2 && + "Cannot return more than two values!"); + + // Since we produced two values, make sure to remember that we + // legalized both of them. + Tmp1 = LegalizeOp(Result); + Tmp2 = LegalizeOp(Result.getValue(1)); + AddLegalizedOperand(Op.getValue(0), Tmp1); + AddLegalizedOperand(Op.getValue(1), Tmp2); + return Op.ResNo ? Tmp2 : Tmp1; case ISD::EHSELECTION: { Tmp1 = LegalizeOp(Node->getOperand(0)); Tmp2 = LegalizeOp(Node->getOperand(1)); @@ -882,7 +893,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { default: assert(0 && "This action is not supported yet!"); case TargetLowering::Expand: { unsigned Reg = TLI.getExceptionSelectorRegister(); - Result = DAG.getCopyFromReg(Tmp2, Reg, VT).getValue(Op.ResNo); + Result = DAG.getCopyFromReg(Tmp2, Reg, VT); } break; case TargetLowering::Custom: @@ -892,12 +903,23 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { case TargetLowering::Legal: { SDOperand Ops[] = { DAG.getConstant(0, VT), Tmp2 }; Result = DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(VT, MVT::Other), - Ops, 2).getValue(Op.ResNo); + Ops, 2); break; } } } - break; + if (Result.Val->getNumValues() == 1) break; + + assert(Result.Val->getNumValues() == 2 && + "Cannot return more than two values!"); + + // Since we produced two values, make sure to remember that we + // legalized both of them. + Tmp1 = LegalizeOp(Result); + Tmp2 = LegalizeOp(Result.getValue(1)); + AddLegalizedOperand(Op.getValue(0), Tmp1); + AddLegalizedOperand(Op.getValue(1), Tmp2); + return Op.ResNo ? Tmp2 : Tmp1; case ISD::EH_RETURN: { MVT::ValueType VT = Node->getValueType(0); // The only "good" option for this node is to custom lower it. -- cgit v1.2.3