Skip to content

Commit 7f02367

Browse files
DinoVmeta-codesync[bot]
authored andcommitted
Fix simplify pass for simplifying method call to vectorcall on 3.14
Summary: On 3.14 the order of the arguments to CALL_METHOD has changed, and NULL is now indicated with a NULL self. This fixes up our optimization of simplify CallMethod -> Vectorcall to account for this. Reviewed By: mpage Differential Revision: D88116848 fbshipit-source-id: 7f5f32a92f6307b62568b3d0c383d5eb3554ce71
1 parent 30e121d commit 7f02367

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

cinderx/Jit/hir/simplify.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,16 +1475,32 @@ static Register* resolveArgs(
14751475
Register* simplifyCallMethod(Env& env, const CallMethod* instr) {
14761476
// If this is statically known to be trying to call a function, update to
14771477
// using a VectorCall directly.
1478-
if (instr->func()->type() <= TNullptr) {
1479-
auto call = env.emitRawInstr<VectorCall>(
1480-
instr->NumOperands() - 1,
1481-
env.func.env.AllocateRegister(),
1482-
instr->flags(),
1483-
*instr->frameState());
1484-
for (size_t i = 1; i < instr->NumOperands(); ++i) {
1485-
call->SetOperand(i - 1, instr->GetOperand(i));
1478+
if constexpr (PY_VERSION_HEX >= 0x030E0000) {
1479+
if (instr->self()->type() <= TNullptr) {
1480+
auto call = env.emitRawInstr<VectorCall>(
1481+
instr->NumOperands() - 1,
1482+
env.func.env.AllocateRegister(),
1483+
instr->flags(),
1484+
*instr->frameState());
1485+
call->SetOperand(0, instr->GetOperand(0));
1486+
for (size_t i = 2; i < instr->NumOperands(); ++i) {
1487+
call->SetOperand(i - 1, instr->GetOperand(i));
1488+
}
1489+
call->output()->set_type(instr->output()->type());
1490+
return call->output();
1491+
}
1492+
} else {
1493+
if (instr->func()->type() <= TNullptr) {
1494+
auto call = env.emitRawInstr<VectorCall>(
1495+
instr->NumOperands() - 1,
1496+
env.func.env.AllocateRegister(),
1497+
instr->flags(),
1498+
*instr->frameState());
1499+
for (size_t i = 1; i < instr->NumOperands(); ++i) {
1500+
call->SetOperand(i - 1, instr->GetOperand(i));
1501+
}
1502+
return call->output();
14861503
}
1487-
return call->output();
14881504
}
14891505

14901506
return nullptr;

0 commit comments

Comments
 (0)