Hit a showstopper issue
Dibyendu Majumdar
mobile@majumdar.org.uk
Thu Jan 1 00:00:00 GMT 2015
On 15 June 2015 at 01:51, David Malcolm <dmalcolm@redhat.com> wrote:
> On Sun, 2015-06-14 at 21:00 +0100, Dibyendu Majumdar wrote:
>> In Lua, redundant bytecodes are emitted that end up being unreachable
>> blocks in the generated code. In LLVM these unreachable blocks are
>> simply eliminated during optimization. But libgccjit is failing with
>> an error.
>
> The idea of this check was an attempt to be helpful, in that in other
> bytecode compilers I've worked on, an unreachable block meant a bug in
> the compiler, and the check has helped me track down bugs in those.
>
> Clearly this check is unhelpful for Lua, so maybe we need an option to
> disable it, something like:
> GCC_JIT_BOOL_OPTION_ERROR_ON_UNREACHABLE_BLOCKS
> or somesuch.
>
Yes - although I am not sure of the value of this check as it is legal
to have unreachable blocks of code and I can think of scenarios where
they may be used deliberately - for instance what appears unreachable
may become reachable given coroutines and closures. An unreachable
piece of code may be a place holder for some future hot patch. Of
course in such cases the optimization must be disabled but the
decision should not be made by the JIT library.
I apologize for bringing in LLVM comparison again - but they have a
model that seems to work just right. Basically the LLVM
verifier/compiler will detect invalid blocks and conrol flow - which
is more important for debugging purposes. Usually a bug will manifest
itself in some corruption in the control flow - e.g. variable not
accessible in all code paths and such - LLVM detects these and raises
errors. I am not sure of the extent of the validation performed in
libgccjit - but perhaps if the validation was more extensive then that
would suffice?
In other words I am asking whether this option is actually a
workaround for lack of sufficient validation of the control flow?
Regards
Dibyendu
More information about the Jit
mailing list