llvm.org GIT mirror llvm / b027fa0
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 Duncan Sands 12 years ago
2 changed file(s) with 72 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
857857 default: assert(0 && "This action is not supported yet!");
858858 case TargetLowering::Expand: {
859859 unsigned Reg = TLI.getExceptionAddressRegister();
860 Result = DAG.getCopyFromReg(Tmp1, Reg, VT).getValue(Op.ResNo);
860 Result = DAG.getCopyFromReg(Tmp1, Reg, VT);
861861 }
862862 break;
863863 case TargetLowering::Custom:
867867 case TargetLowering::Legal: {
868868 SDOperand Ops[] = { DAG.getConstant(0, VT), Tmp1 };
869869 Result = DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(VT, MVT::Other),
870 Ops, 2).getValue(Op.ResNo);
871 break;
872 }
873 }
874 }
875 break;
870 Ops, 2);
871 break;
872 }
873 }
874 }
875 if (Result.Val->getNumValues() == 1) break;
876
877 assert(Result.Val->getNumValues() == 2 &&
878 "Cannot return more than two values!");
879
880 // Since we produced two values, make sure to remember that we
881 // legalized both of them.
882 Tmp1 = LegalizeOp(Result);
883 Tmp2 = LegalizeOp(Result.getValue(1));
884 AddLegalizedOperand(Op.getValue(0), Tmp1);
885 AddLegalizedOperand(Op.getValue(1), Tmp2);
886 return Op.ResNo ? Tmp2 : Tmp1;
876887 case ISD::EHSELECTION: {
877888 Tmp1 = LegalizeOp(Node->getOperand(0));
878889 Tmp2 = LegalizeOp(Node->getOperand(1));
881892 default: assert(0 && "This action is not supported yet!");
882893 case TargetLowering::Expand: {
883894 unsigned Reg = TLI.getExceptionSelectorRegister();
884 Result = DAG.getCopyFromReg(Tmp2, Reg, VT).getValue(Op.ResNo);
895 Result = DAG.getCopyFromReg(Tmp2, Reg, VT);
885896 }
886897 break;
887898 case TargetLowering::Custom:
891902 case TargetLowering::Legal: {
892903 SDOperand Ops[] = { DAG.getConstant(0, VT), Tmp2 };
893904 Result = DAG.getNode(ISD::MERGE_VALUES, DAG.getVTList(VT, MVT::Other),
894 Ops, 2).getValue(Op.ResNo);
895 break;
896 }
897 }
898 }
899 break;
905 Ops, 2);
906 break;
907 }
908 }
909 }
910 if (Result.Val->getNumValues() == 1) break;
911
912 assert(Result.Val->getNumValues() == 2 &&
913 "Cannot return more than two values!");
914
915 // Since we produced two values, make sure to remember that we
916 // legalized both of them.
917 Tmp1 = LegalizeOp(Result);
918 Tmp2 = LegalizeOp(Result.getValue(1));
919 AddLegalizedOperand(Op.getValue(0), Tmp1);
920 AddLegalizedOperand(Op.getValue(1), Tmp2);
921 return Op.ResNo ? Tmp2 : Tmp1;
900922 case ISD::EH_RETURN: {
901923 MVT::ValueType VT = Node->getValueType(0);
902924 // The only "good" option for this node is to custom lower it.
0 ; RUN: llvm-as < %s | llc -enable-eh
1 ; PR1833
2
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
4 target triple = "i686-pc-linux-gnu"
5 %struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo }
6 %struct.__type_info_pseudo = type { i8*, i8* }
7 @_ZTI2e1 = external constant %struct.__class_type_info_pseudo ; <%struct.__class_type_info_pseudo*> [#uses=1]
8
9 define void @_Z7ex_testv() {
10 entry:
11 invoke void @__cxa_throw( i8* null, i8* bitcast (%struct.__class_type_info_pseudo* @_ZTI2e1 to i8*), void (i8*)* null ) noreturn
12 to label %UnifiedUnreachableBlock unwind label %lpad
13
14 bb14: ; preds = %lpad
15 unreachable
16
17 lpad: ; preds = %entry
18 invoke void @__cxa_end_catch( )
19 to label %bb14 unwind label %lpad17
20
21 lpad17: ; preds = %lpad
22 %eh_select20 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32( i8* null, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null ) ; [#uses=0]
23 unreachable
24
25 UnifiedUnreachableBlock: ; preds = %entry
26 unreachable
27 }
28
29 declare void @__cxa_throw(i8*, i8*, void (i8*)*) noreturn
30
31 declare i32 @llvm.eh.selector.i32(i8*, i8*, ...)
32
33 declare void @__cxa_end_catch()
34
35 declare i32 @__gxx_personality_v0(...)