summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-04-06 01:33:49 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-04-06 01:33:49 +0000
commit65a60670e8a8e8380284d45f831f38baf6faba60 (patch)
treec826446d9f8c66f121eec90809b20c330cc58e22 /llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
parent66a69ceed9d35d932892c58b683a21451bf92e5a (diff)
downloadbcm5719-llvm-65a60670e8a8e8380284d45f831f38baf6faba60.tar.gz
bcm5719-llvm-65a60670e8a8e8380284d45f831f38baf6faba60.zip
Lower @llvm.experimental.deoptimize as a noreturn call
While preserving the return value for @llvm.experimental.deoptimize at the IR level is useful during mid-level optimization, doing so at the machine instruction level requires generating some extra code and a return that is non-ideal. This change has LLVM lower ``` %val = call @llvm.experimental.deoptimize ret %val ``` to effectively ``` call @__llvm_deoptimize() unreachable ``` instead. llvm-svn: 265502
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp26
1 files changed, 20 insertions, 6 deletions
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()));
}
OpenPOWER on IntegriCloud