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)
commit70d18df18fab3d9d73b724b1042abaa536289bbe
tree79421a3ad1bc8128379b8fd42fd2110079e127e1
parent18ad2e54ab8012e3dd8bffc6f0e1a98683afa2fc
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.

llvm-svn: 239114
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/test/CodeGen/X86/statepoint-far-call.ll [new file with mode: 0644]