* PTMLEmitter is now a concept subsuming Emitter.
* PTMLStreamEmitter is a concrete emitter implementing PTMLEmitter.
* Indentation no longer includes PTML tags.
* PTMLTagEmitter is no longer default-constructible or reusable.
In the new pipeline the root module is split off in its individual
isolated modules at the end of `isolate`. Before splitting, there are a
lot of global variables in the root module and only a small part is
going to be needed after splitting for each module. To avoid excessive
memory usage employ `ConservativeModuleCloner` in `Isolate` so that
only the needed global variables are actually cloned when splitting off.
Re-organize the variants of `libtcg-helpers-*.bc` as such:
* `libtcg-helpers-full-$ARCH.bc`: unchanged, contains all helper
function with their bodies and all CSVs.
* `libtcg-helpers-declarations-only-$ARCH.bc`: all helper
functions have been turned to declarations. All CSVs (except a couple
of special ones) have been dropped.
* `libtcg-helpers-to-inline-$ARCH.bc`: only functions with the
`revng_inline` section retain their body. Only CSVs that are used by
these functions are present.
Lift now loads only the `declarations-only` variant of helpers, as
their body is not required until `inline-helpers`. In `inline-helpers`
the `to-inline` variant is loaded and linked, which then allows the
helpers to be inlined.
Add the `SimplePassManager` and `SimpleFunctionPassManager` classes
which add wrappers around the new LLVM pass manager. Change all the
applicable uses of the legacy pass manager with the wrapper.
When calling `programCounterHandler`, instead of relying on the presence
of the `root` function, which might be absent, use a guaranteed
reference to the module.
Move member declaration to the top of the class definition of
`GeneratedCodeBasicInfo` and initialize primitive members.
Merge the `run` method into the constructor since all uses have them
happening close to each other.
`Alignment` was `unsigned`. However we were doing bit operations,
bitwise negation in particular, which was supposed to happen on
64-bits, to initialize a `ConstantInt` mask.
This commit ensures relocations imported from PE/COFF binaries have
generic `Address`. The fact that this was not the case lead to not
detecting dynamic calls.
The commit also improves logging and fixes the handling of maximum depth
visit of the PDB importer.
Add infrastructure to pypeline that allows containers to be notified
when they are being used last, this allows two things:
* `Pipe`s eagerly clearing those containers once they are done reading
their contents
* `ScheduledTask`s clearing those out at the end of their execution in
case the pipe did not do it
This overall should improve memory usage as container no longer take up
memory if they are no longer used as part of a `Schedule`.
Implement trivial memory optimizations on the `isolate` pipe:
* Clone the `root` module right away to the correct context before
performing isolation
* Delete the `root` function's body right after isolation
* Delete the isolated function body from the cloned module after it has
been `cloneFiltered`-ed into the output container
Fix the behavior of binary importers by propagating the path of the
input binary from revng2 downwards, allowing finding `.debug` files in
the correct paths.
Store the contents of the files deserialized by `BinariesContainer` to
disk via `TemporaryFile`. This also allows some pipes to avoid shuffling
data around since they needed a file on disk anyways.
Sometimes QEMU will emit code that reads a local temporary *before* it
is assigned in the `TranslationBlock`. This usually happens when lifting
non-code, but it's still a problem since it leads to phis around the
dispatcher, which we don't want.
For example, consider the following x86-64 code:
```
0000000140002000 <.text>:
140002000: f0 lock
140002001: 38 00 cmpb %al, (%rax)
```
It leads to:
```
[libtcg] Translation starting from 0x140002000:Generic64
[libtcg] ---- 0000000040002000
[libtcg] mov_i64 loc2,rax
[libtcg] mov_i64 loc1,rax
[libtcg] mov_i64 cc_src,loc1
[libtcg] mov_i64 loc8,loc0
[libtcg] sub_i64 cc_dst,loc0,loc1
[libtcg] discard cc_src2
[libtcg] discard cc_op
```
Note how `loc0` is read before being initialized.
Currently we zero-initialize all the temporaries. It would be in
princple possible to detect those that need the initialization, which
would also enable us to emit a warning.
When initializing `revng::InitRevng` it is assumed by its parent,
`InitLLVM`, that the lifetime of `Argv` and be equivalent to
static, because it might be later retrieved to print it in case of a
crash. This works with the traditional `main`, however in the pipebox
the string passed are not guaranteed to have that lifetime. This commits
moves ownership of the strings to a class that stores them to avoid this
problem.
In the same vein as `PureLLVMPassesPipe`, add a pipe to pypeline that
allows running arbitrarily-specified MLIR passes that do not depend on
the model.
In equivalence with `LLVMFunctionMixin`, add a mixin that allows
writing a pipe that instead of defining the `runOnFunction` method it
defines the `runOnCliftFunction` which receives both the
`module::Function` and the `FunctionOp`.