Alamvic / druid

Meta-compiler to generate an optimised JIT compiler frontend based on an Interpreter definition
8 stars 6 forks source link

If an IR's BasicBlock jumps to itself, the Cogit code generated from it will be broken #123

Open doste opened 5 months ago

doste commented 5 months ago

When dealing with an IR that has a self loop, the IR->Cogit translation is broken. If a BasicBlock has a Jump to itself, the Cogit code generated will have an infinite loop.

A concrete example of this can be seen when generating the primitive primitiveLoopIncrementing. Here we can see that the corresponding IR, after some the optimizations, will have a BasicBlock jumping to itself.

To check this we can do something like this:

        cfg := self generateBasicDruidIRFor: #primitiveLoopIncrementing.
    self optimize: cfg.
    1halt.

There if we inspect the CFG we can see the said block. Then, we can check that gen_primitiveLoopIncrementing contains an infinite loop.