[Statepoint] Always spill base pointer.
authorDenis Antrushin <dantrushin@gmail.com>
Thu, 27 Aug 2020 12:51:30 +0000 (19:51 +0700)
committerDenis Antrushin <dantrushin@gmail.com>
Fri, 28 Aug 2020 16:22:07 +0000 (23:22 +0700)
commitfabd4c1ae1fc573eb83ba9541e133a265c5549da
tree039adafda3f3d7c9d5c47bc377ba00337fbb9461
parent46e0ced762ce2c32bc846b5c0129c3b5020ca5d9
[Statepoint] Always spill base pointer.

There is a subtle problem with new statepoint lowering scheme
when base and pointers are the same (see PR46917 for more context):

%1 = STATEPOINT ... %0, %0(tied-def 0)...

if, for some reason, register allocator desides to put two instances
of %0 into two different objects (registers or spill slots), we may
end up with

$reg3 = STATEPOINT ... $reg2, $reg1(tied-def 0)...

and nothing will prevent later passes to sink uses of $reg2 below
statepoint, which is incorrect.

As a short term solution, always put base pointers on stack during
lowering.
A longer term solution may be to rework MIR statepoint format to
avoid GC pointer duplication in statepoint argument list.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D86712
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/test/CodeGen/X86/statepoint-vreg-details.ll
llvm/test/CodeGen/X86/statepoint-vreg.ll