SDValue ActualCallee = Builder.getValue(ISP.getActualCallee());
- // Handle immediate and symbolic callees.
- if (auto *ConstCallee = dyn_cast<ConstantSDNode>(ActualCallee.getNode()))
- ActualCallee = Builder.DAG.getIntPtrConstant(ConstCallee->getZExtValue(),
- Builder.getCurSDLoc(),
- /*isTarget=*/true);
- else if (auto *SymbolicCallee =
- dyn_cast<GlobalAddressSDNode>(ActualCallee.getNode()))
- ActualCallee = Builder.DAG.getTargetGlobalAddress(
- SymbolicCallee->getGlobal(), SDLoc(SymbolicCallee),
- SymbolicCallee->getValueType(0));
-
assert(CS.getCallingConv() != CallingConv::AnyReg &&
"anyregcc is not supported on statepoints!");
--- /dev/null
+; RUN: llc < %s | FileCheck %s\r
+; Test to check that Statepoints with X64 far-immediate targets\r
+; are lowered correctly to an indirect call via a scratch register.\r
+\r
+target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"\r
+target triple = "x86_64-pc-win64"\r
+\r
+define void @test_far_call() gc "statepoint-example" {\r
+; CHECK-LABEL: test_far_call\r
+; CHECK: pushq %rax\r
+; CHECK: movabsq $140727162896504, %rax \r
+; CHECK: callq *%rax\r
+; CHECK: popq %rax\r
+; CHECK: retq\r
+\r
+entry:\r
+ %safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* inttoptr (i64 140727162896504 to void ()*), i32 0, i32 0, i32 0, i32 0)\r
+ ret void\r
+}\r
+\r
+declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) \r
+\r