Skip to content

Commit

Permalink
Type the return of InvokeStaticFunction in LIR
Browse files Browse the repository at this point in the history
Summary:
This ended up biting me while I was working on de-stringifying IntBinaryOp.  I
was getting a crash in `make testcinder_jit` due to an invalid `imul bl, cl`
instruction being generated (8-bit imul has to use ax and al).

I tracked down the issue to this small repro, P580265190.  Note how IntBinaryOp
is getting a value that comes from an InvokeStaticFunction.  In HIR, the return
value is typed as CInt8, but the LIR generator generated `Mul RAX:Object,
RCX:8bit`.
This means the `rewriteByteMultiply` function in postalloc.cpp
(https://fburl.com/code/770swxgu) can't kick in for cases like this because the
first operand is not being correctly typed as an 8-bit argument.

Adding the return type to the Call generated for the InvokeStaticFunction fixes
the crash for me.

Test Plan:
`make -j testcinder_jit`, both with and without changes to use
`BasicBlockBuilder.appendInstr()` for IntBinaryOp in D42143109.

Reviewers: jbower, carljm, #cinderjit

Reviewed By: carljm

Differential Revision: https://phabricator.intern.facebook.com/D42143037

Tags: cinder-310-exclusive
  • Loading branch information
alexmalyshev authored and Service User committed Jan 9, 2023
1 parent 46b08d1 commit 80b52b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Jit/lir/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,8 @@ LIRGenerator::TranslatedBlock LIRGenerator::TranslateOneBasicBlock(
std::string tmp_id = GetSafeTempName();
bbb.AppendCode(
"Load {}, {:#x}", tmp_id, reinterpret_cast<uint64_t>(indir));
ss << "Call " << instr->dst()->name() << ", " << tmp_id;
ss << "Call " << instr->dst()->name() << ":" << instr->dst()->type()
<< ", " << tmp_id;
}

for (size_t i = 0; i < nargs; i++) {
Expand Down

0 comments on commit 80b52b4

Please sign in to comment.