From 340dafa6bdc075c11fcfa2ed8c415cc0c6be5427 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 22 Mar 2016 18:10:39 +0000 Subject: [PATCH] Allow lowering call sites with both funclets and deopt state Lowering funclets is a no-op, so we can just go ahead and lower the deopt state. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264078 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../SelectionDAG/StatepointLowering.cpp | 6 +--- test/CodeGen/X86/deopt-bundles.ll | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index fb0cba196ba..ad339064b14 100644 --- a/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -837,16 +837,12 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP, void SelectionDAGBuilder::LowerCallSiteWithDeoptBundle( ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB) { - assert(CS.getNumOperandBundles() == 1 && - "Only deopt operand bundles can be lowered!"); - StatepointLoweringInfo SI(DAG); unsigned ArgBeginIndex = CS.arg_begin() - CS.getInstruction()->op_begin(); populateCallLoweringInfo(SI.CLI, CS, ArgBeginIndex, CS.getNumArgOperands(), Callee, CS.getType(), false); - auto DeoptBundle = CS.getOperandBundleAt(0); - assert(DeoptBundle.getTagID() == LLVMContext::OB_deopt && "Should be!"); + auto DeoptBundle = *CS.getOperandBundle(LLVMContext::OB_deopt); unsigned DefaultID = StatepointDirectives::DeoptBundleStatepointID; diff --git a/test/CodeGen/X86/deopt-bundles.ll b/test/CodeGen/X86/deopt-bundles.ll index 4b575853270..3a135c38f14 100644 --- a/test/CodeGen/X86/deopt-bundles.ll +++ b/test/CodeGen/X86/deopt-bundles.ll @@ -35,6 +35,13 @@ target triple = "x86_64-apple-macosx10.11.0" ; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] ; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 3 [encoding: .byte 4, .byte 8, .short 0, .int 3] ; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers +; STACKMAPS-NEXT: Stack Maps: callsite 4243 +; STACKMAPS-NEXT: Stack Maps: has 4 locations +; STACKMAPS-NEXT: Stack Maps: Loc 0: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] +; STACKMAPS-NEXT: Stack Maps: Loc 1: Constant 0 [encoding: .byte 4, .byte 8, .short 0, .int 0] +; STACKMAPS-NEXT: Stack Maps: Loc 2: Constant 1 [encoding: .byte 4, .byte 8, .short 0, .int 1] +; STACKMAPS-NEXT: Stack Maps: Loc 3: Constant 55 [encoding: .byte 4, .byte 8, .short 0, .int 55] +; STACKMAPS-NEXT: Stack Maps: has 0 live-out registers declare i32 @callee_0() @@ -103,3 +110,25 @@ uw: ; CHECK: popq %rcx ; CHECK: retq } + +define i32 @invoker_2() personality i32 (...)* @__CxxFrameHandler3 { +entry: + %val = invoke i32 @callee_1(i32 1) + to label %try.cont unwind label %catch.dispatch + +catch.dispatch: + %cs1 = catchswitch within none [label %catch] unwind to caller + +catch: + %cp1 = catchpad within %cs1 [i8* null, i32 64, i8* null] + br label %loop + +loop: + %val2 = call i32 @callee_1(i32 100) "statepoint-id"="4243" [ "funclet"(token %cp1), "deopt"(i32 55) ] + catchret from %cp1 to label %try.cont + +try.cont: + ret i32 0 +} + +declare i32 @__CxxFrameHandler3(...)