From 1da20a71d1bbabc472f281208be77475550be751 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Fri, 23 Feb 2007 21:45:01 +0000 Subject: [PATCH] Handle improper cast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34535 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 5f1c942e960..c35f02a06ca 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -484,7 +484,9 @@ public: unsigned Opc); bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB); void ExportFromCurrentBlock(Value *V); - void LowerCallTo(CallInst &I, SDOperand Callee, unsigned OpIdx); + void LowerCallTo(Instruction &I, + const Type *CalledValueTy, unsigned CallingConv, + bool IsTailCall, SDOperand Callee, unsigned OpIdx); // Terminator instructions. void visitRet(ReturnInst &I); @@ -1118,7 +1120,11 @@ void SelectionDAGLowering::visitInvoke(InvokeInst &I) { DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(), DAG.getConstant(BeginLabel, MVT::i32))); - LowerCallTo((CallInst&)I, getValue(I.getOperand(0)), 3); + LowerCallTo(I, I.getCalledValue()->getType(), + I.getCallingConv(), + false, + getValue(I.getOperand(0)), + 3); // Insert a label before the invoke call to mark the try range. // This can be used to detect deletion of the invoke via the @@ -2246,9 +2252,12 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { } -void SelectionDAGLowering::LowerCallTo(CallInst &I, +void SelectionDAGLowering::LowerCallTo(Instruction &I, + const Type *CalledValueTy, + unsigned CallingConv, + bool IsTailCall, SDOperand Callee, unsigned OpIdx) { - const PointerType *PT = cast(I.getCalledValue()->getType()); + const PointerType *PT = cast(CalledValueTy); const FunctionType *FTy = cast(PT->getElementType()); TargetLowering::ArgListTy Args; @@ -2267,7 +2276,7 @@ void SelectionDAGLowering::LowerCallTo(CallInst &I, std::pair Result = TLI.LowerCallTo(getRoot(), I.getType(), FTy->paramHasAttr(0,FunctionType::SExtAttribute), - FTy->isVarArg(), I.getCallingConv(), I.isTailCall(), + FTy->isVarArg(), CallingConv, IsTailCall, Callee, Args, DAG); if (I.getType() != Type::VoidTy) setValue(&I, Result.first); @@ -2333,7 +2342,11 @@ void SelectionDAGLowering::visitCall(CallInst &I) { else Callee = DAG.getExternalSymbol(RenameFn, TLI.getPointerTy()); - LowerCallTo(I, Callee, 1); + LowerCallTo(I, I.getCalledValue()->getType(), + I.getCallingConv(), + I.isTailCall(), + Callee, + 1); }