diff options
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 26 |
3 files changed, 35 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 91c0a04a3b4..f6b4262ffd7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1377,6 +1377,18 @@ void SelectionDAGBuilder::visitRet(const ReturnInst &I) { SmallVector<ISD::OutputArg, 8> Outs; SmallVector<SDValue, 8> OutVals; + // Calls to @llvm.experimental.deoptimize don't generate a return value, so + // lower + // + // %val = call <ty> @llvm.experimental.deoptimize() + // ret <ty> %val + // + // differently. + if (I.getParent()->getTerminatingDeoptimizeCall()) { + LowerDeoptimizingReturn(); + return; + } + if (!FuncInfo.CanLowerReturn) { unsigned DemoteReg = FuncInfo.DemoteRegister; const Function *F = I.getParent()->getParent(); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 214c5107041..2d2002680ba 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -779,10 +779,12 @@ public: const BasicBlock *EHPadBB); void LowerDeoptimizeCall(const CallInst *CI); + void LowerDeoptimizingReturn(); void LowerCallSiteWithDeoptBundleImpl(ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB, - bool VarArgDisallowed); + bool VarArgDisallowed, + bool ForceVoidReturnTy); private: // Terminator instructions. diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index edec366aeaa..f489e3b1c8c 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -823,11 +823,13 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP, void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl( ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB, - bool VarArgDisallowed) { + bool VarArgDisallowed, bool ForceVoidReturnTy) { StatepointLoweringInfo SI(DAG); unsigned ArgBeginIndex = CS.arg_begin() - CS.getInstruction()->op_begin(); - populateCallLoweringInfo(SI.CLI, CS, ArgBeginIndex, CS.getNumArgOperands(), - Callee, CS.getType(), false); + populateCallLoweringInfo( + SI.CLI, CS, ArgBeginIndex, CS.getNumArgOperands(), Callee, + ForceVoidReturnTy ? Type::getVoidTy(*DAG.getContext()) : CS.getType(), + false); if (!VarArgDisallowed) SI.CLI.IsVarArg = CS.getFunctionType()->isVarArg(); @@ -856,7 +858,8 @@ void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl( void SelectionDAGBuilder::LowerCallSiteWithDeoptBundle( ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB) { LowerCallSiteWithDeoptBundleImpl(CS, Callee, EHPadBB, - /* VarArgDisallowed = */ false); + /* VarArgDisallowed = */ false, + /* ForceVoidReturnTy = */ false); } void SelectionDAGBuilder::visitGCResult(const CallInst &CI) { @@ -941,7 +944,18 @@ void SelectionDAGBuilder::LowerDeoptimizeCall(const CallInst *CI) { TLI.getPointerTy(DAG.getDataLayout())); // We don't lower calls to __llvm_deoptimize as varargs, but as a regular - // call. + // call. We also do not lower the return value to any virtual register, and + // change the immediately following return to a trap instruction. LowerCallSiteWithDeoptBundleImpl(CI, Callee, /* EHPadBB = */ nullptr, - /* VarArgDisallowed = */ true); + /* VarArgDisallowed = */ true, + /* ForceVoidReturnTy = */ true); +} + +void SelectionDAGBuilder::LowerDeoptimizingReturn() { + // We do not lower the return value from llvm.deoptimize to any virtual + // register, and change the immediately following return to a trap + // instruction. + if (DAG.getTarget().Options.TrapUnreachable) + DAG.setRoot( + DAG.getNode(ISD::TRAP, getCurSDLoc(), MVT::Other, DAG.getRoot())); } |