Custom opcodes that are tagged AllocatesLocalVariable never have
arguments that should be replaced with SegmentRef or cstringLiteral.
Constant arguments or those custom opcodes are actually used to encode
another kinds of informations so they should be preserved.
This commit prevents that replacements to happen.
With the new backend design we should never need to emit C code for
a llvm::GlobalVariable.
The new backend prints a warning in C if that happens.
This commit adds a check in our recompilation tests to ensure that never
happens.
This commit refactors the C Backend as follows.
- The emission of basic blocks is now statement based.
There are some instructions that are handled as statements.
Those instructions are the points where the codegen starts from when
emitting C.
Conversely, all the other instructions are initially ignored when
iterating on instructions in a basic block, and are only reached when
traversing the dataflow that originates from statements.
- The TokenMap, that originally included all the string representing all
the instructions, is now used only to store the names of funciton
arguments and instructions representing local variables.
- Starting from each statement-like instruction, the C codegen is driven
by a traversal of the dataflow of the operands. The dataflow is
traversed recursively with the `getToken` method, materializing
strings on the fly until the visit reaches "leaves" i.e. instruction
that represent local variables, constants, or function arguments.
Adopting this approach allowed to reduce the peak memory consumption of
the backend, as well as making it faster on our benchmarks.
Before this commit, the pass was never emitting assignments for helpers.
This was a leftover.
With this commit, the pass now handles calls to helpers in an
homogeneous way to calls to isolated functions.
Before this commit, every time we decided to serialize an Instruction we
were considering other instructions that might have interfering side
effects with it.
This was resulting in many more instructions than necessary being marked
with HasInterferingSideEffects.
This commits fixes this problem, by only checking interfering side
effects when an Instruction is marked as having side effects.
Since when we added the -exit-ssa pass, loads and stores are never
supposed to reach the C backend anymore.
This commit drops the code that supports them, that was effectively dead
code since a quite long time.
Since when we added the -exit-ssa pass, allocas are never supposed to
reach the C backend anymore.
This commit drops the code that supports them, that was effectively dead
code since a quite long time.