Statepoint: Fix handling of Far Immediate calls
authorSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Thu, 4 Jun 2015 23:03:21 +0000 (23:03 +0000)
committerSwaroop Sridhar <Swaroop.Sridhar@microsoft.com>
Thu, 4 Jun 2015 23:03:21 +0000 (23:03 +0000)
commitbb3883dfbab9a48176497066ed40911431e0fda8
tree35166af402fa5f2de0ca7fe2f4a130c644b2da79
parent1ea35c2d5253e1ab7066e9433aa5e1dde02e8723
Statepoint: Fix handling of Far Immediate calls

gc.statepoint intrinsics with a far immediate call target
were lowered incorrectly as pc-rel32 calls.

This change fixes the problem, and generates an indirect call
via a scratch register.

For example:

Intrinsic:
  %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)

Old Incorrect Lowering:
  callq 140727162896504

New Correct Lowering:
  movabsq $140727162896504, %rax
  callq *%rax

In lowerCallFromStatepoint(), the callee-target was modified and
represented as a "TargetConstant" node, rather than a "Constant" node.
Undoing this modification enabled LowerCall() to generate the
correct CALL instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239114 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/StatepointLowering.cpp
test/CodeGen/X86/statepoint-far-call.ll [new file with mode: 0644]