Fix the recently added anyregcc convention to handle spilled operands.

Fixes <rdar://15432754> [JS] Assertion: "Folded a def to a non-store!"

The primary purpose of anyregcc is to prevent a patchpoint's call
arguments and return value from being spilled. They must be available
in a register, although the calling convention does not pin the
register. It's up to the front end to avoid using this convention for
calls with more arguments than allocatable registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194428 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick
2013-11-11 22:40:25 +00:00
parent 5a34980b4e
commit 01846af6ed
2 changed files with 47 additions and 9 deletions

View File

@@ -4207,10 +4207,19 @@ static MachineInstr* foldPatchpoint(MachineFunction &MF,
MachineInstrBuilder MIB(MF, NewMI);
bool isPatchPoint = MI->getOpcode() == TargetOpcode::PATCHPOINT;
// For PatchPoint, the call args are not foldable.
unsigned NumCallArgs = MI->getOperand(StartIdx+3).getImm();
StartIdx = isPatchPoint ?
StartIdx + MI->getOperand(StartIdx+3).getImm() + 5 :
StartIdx + NumCallArgs + 5 :
StartIdx + 2;
// Return false if any operands requested for folding are not foldable (not
// part of the stackmap's live values).
for (SmallVectorImpl<unsigned>::const_iterator I = Ops.begin(), E = Ops.end();
I != E; ++I) {
if (*I < StartIdx)
return 0;
}
// No need to fold return, the meta data, and function arguments
for (unsigned i = 0; i < StartIdx; ++i)
MIB.addOperand(MI->getOperand(i));