[Tarantool-patches] [PATCH luajit] Fix TNEW load forwarding with instable types.

Igor Munkin imun at tarantool.org
Mon Jul 3 22:24:01 MSK 2023


Sergey,

Thanks for the patch! LGTM, considering the fixes made for the comments
left by Max.

On 11.05.23, Sergey Kaplun via Tarantool-patches wrote:
> From: Mike Pall <mike>
> 
> (cherry picked from commit d4c0c6e17ef7edf1f2893bc807746b80612e63e9)
> 
> During loop unrolling IR instructions are coped, substituted and
> re-emitted for the FOLD/CSE/etc. pipeline. Assume, we have the following
> loop-carried dependency: we create a new table or load some stored one
> depends on iteration number. In case when we copy the emitted ALOAD IR

Side note: Changed the part after the colon the following way
| we create a new table or load the stored one depending on the
| iteration number.

> instruction (from from the stored table), we copy it as is, including
> loading type. But the ALOAD from the new table created (on the previous
> iteration) should have nil type, so the assertion in `fwd_ahload()` is
> failed.
> 
> This patch replaces the assertion to `return 0` to avoid the assertion
> failure and stop forwarding in such situations.
> 
> But the emitted type-guarded ALOAD will lead to the persistent failure
> of the assertion guard on the trace. Hence, another one fix should be

Side note: Removed this sentence, as we discussed.

> added. Also, TDUP IR is affected, too.
> See also the issue mentioned in the test.
> 
> Sergey Kaplun:
> * added the description and the test for the problem
> 
> Part of tarantool/tarantool#8516
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-994-instable-types-during-loop-unroll
> PR: https://github.com/tarantool/tarantool/pull/8642
> Related issues:
> * https://github.com/tarantool/tarantool/issues/8516
> * https://github.com/LuaJIT/LuaJIT/issues/994
> 
> I don't mention the 994 intentionally to avoid Mike bothering. Also, it
> isn't the origin of this commit. Quite the opposite: as a result of this
> backporting the following issue was created.
> 
> I prefer to backport the patches (this one and the prospective for 994)
> separately. So, after this patch is backported, it doesn't add any
> critical bugs (always failing guard just creates a new side trace), but
> helps to avoid conflicts for future backporting (sadly remembered
> "Improve assertions.").
> 
>  src/lj_opt_mem.c                              |  3 +-
>  ...instable-types-during-loop-unroll.test.lua | 53 +++++++++++++++++++
>  2 files changed, 55 insertions(+), 1 deletion(-)
>  create mode 100644 test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
> 

<snipped>

> -- 
> 2.34.1
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list