mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
cf42e497aa
This commit introduces the Function Isolation Pass. We use the information provided by the Function Boundaries Detection Pass to organize the code that `revamb` places inside the `root` function in different LLVM functions. To do this we obviously need to introduce some changes and tricks to handle the execution of the translated program. The main idea is to have two different realms (one where the isolated functions live, one in which we have basically the old root function). We start the execution from the realm of the *non isolated* functions, and we transfer, as soon as possible, the execution to the *isolated functions* realm. We then have a fallback mechanism to restore the execution in the right place in the *non isolated* functions realm, and so on. The largest change, besides the re-organization of the code in different functions, is the use of the exception handling mechanism provided by the LLVM framework in order to be able to manage the switch between the two realms. We also introduce the `support.h` header file, which contains a couple of definitions used by `support.c` and that need to be shared with some of the components involved in the translation process. We have defined some helper functions, directly in C, that we use both for handling the exception mechanism and for giving extra debug informations when an exception is raised. The `revamb-dump` utility now supports the `-i` option to specify the path were to save the new LLVM module. The `translate` utility now supports the `-i` option that produces a binary in which the function isolation has been applied. We also introduced some tests that apply the function isolation pass to the `Runtime/` tests already present. In this way we can verify that the translation and the following function isolation preserve the behavior of the program. When serializing the new LLVM module we regenerate the metadata used for debug purposes, and for doing this, since we not longer have only the `root` function, we have changed some details in the `DebugHelper` class in order to be able to emit the metadata for all the functions of our interest in a single shot.
53 lines
2.0 KiB
ReStructuredText
53 lines
2.0 KiB
ReStructuredText
*********
|
|
translate
|
|
*********
|
|
|
|
----------------------------------------------------------------
|
|
translate a program from an architecture to another using revamb
|
|
----------------------------------------------------------------
|
|
|
|
:Author: Alessandro Di Federico <ale+revng@clearmind.me>
|
|
:Date: 2016-12-22
|
|
:Copyright: MIT
|
|
:Version: 0.1
|
|
:Manual section: 1
|
|
:Manual group: rev.ng
|
|
|
|
SYNOPSIS
|
|
========
|
|
|
|
revamb-dump [options] [--] INFILE [revamb options]
|
|
|
|
DESCRIPTION
|
|
===========
|
|
|
|
`translate` is a simple wrapper script which using `revamb` to lift an input
|
|
program to LLVM IR and then compiling it to x86-64.
|
|
|
|
In practice, `translate` first invokes `revamb` then, depending on the options,
|
|
some optimizations are performed using `llc` and or `opt`, and finally the
|
|
generated object file is linked against the require libraries and `support.c`.
|
|
|
|
Options after `INFILE` are forwarded as is to `revamb`.
|
|
|
|
OPTIONS
|
|
=======
|
|
|
|
:``-O0``: Disable optimizations both in the mid-end (`opt`) and the backend
|
|
(`llc`). This is default option.
|
|
:``-O1``: Enable backend optimizations (`llc`).
|
|
:``-O2``: Enable optimizations both in the mid-end (`opt`) and the backend
|
|
(`llc`).
|
|
:``-s``: Skip invoking `revamb`, assumes a file named `INFILE.ll` already
|
|
exists. This is useful for optimizing previously generated code.
|
|
:``-trace``: Enable tracing support: if the `REVAMB_TRACE_PATH` environment
|
|
variable is set at run-time, the translated program will log all
|
|
the executed program counters into the file specified by the
|
|
environment variable. This effect it obtained by linking the
|
|
translated program against the `support-$ARCH-trace.ll` module
|
|
instead of the `support-$ARCH-normal.ll`. Enabling this option
|
|
introduces a non-negligible slow down in the output program, even
|
|
if `REVAMB_TRACE_PATH` is not specified at run-time.
|
|
:``-i``: Optionally apply the function isolation pass before re-compiling the
|
|
program.
|