Perform correct codegen for eh_dwarf_cfa intrinsic.
authorAnton Korobeynikov <asl@math.spbu.ru>
Thu, 23 Aug 2007 07:21:06 +0000 (07:21 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Thu, 23 Aug 2007 07:21:06 +0000 (07:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41316 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

index 78539d454ed7780f24c8d22c86ff9897b4da53f2..1dde705bf59dea08de70e740041887ada4f11ab8 100644 (file)
@@ -2751,11 +2751,19 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
    case Intrinsic::eh_dwarf_cfa: {
      if (ExceptionHandling) {
        MVT::ValueType VT = getValue(I.getOperand(1)).getValueType();
+       SDOperand CfaArg;
+       if (MVT::getSizeInBits(VT) > MVT::getSizeInBits(TLI.getPointerTy()))
+         CfaArg = DAG.getNode(ISD::TRUNCATE,
+                              TLI.getPointerTy(), getValue(I.getOperand(1)));
+       else
+         CfaArg = DAG.getNode(ISD::SIGN_EXTEND,
+                              TLI.getPointerTy(), getValue(I.getOperand(1)));
+       
        SDOperand Offset = DAG.getNode(ISD::ADD,
                                       TLI.getPointerTy(),
                                       DAG.getNode(ISD::FRAME_TO_ARGS_OFFSET,
-                                                  VT),
-                                      getValue(I.getOperand(1)));
+                                                  TLI.getPointerTy()),
+                                      CfaArg);
        setValue(&I, DAG.getNode(ISD::ADD,
                                 TLI.getPointerTy(),
                                 DAG.getNode(ISD::FRAMEADDR,