Commit Graph

1040 Commits

Author SHA1 Message Date
Alessandro Di Federico 2c7fa21065 Enable -inline-helpers 2021-04-30 14:52:25 +02:00
Alessandro Di Federico 0c671ea7ae Introduce RemoveExceptionalCalls
RemoveExceptionalCalls is a simple pass whose goal is to drop all the
calls to functions marked as `Exceptional` and replace them with an
`UnrechableInst`.

This is mainly useful in the decompilation pipeline.
2021-04-30 14:52:25 +02:00
Alessandro Di Federico ce87c30490 Introduce InlineHelpers
InlineHelpers is a simple pass that recursively inlines all the
functions belonging to the section `revng_inline` in isolated functions.
2021-04-30 14:52:25 +02:00
Pietro Fezzardi b6327b0526 PromoteCSVs: fix CSV list initialization 2021-04-30 14:52:25 +02:00
Pietro Fezzardi 223d022968 replaceFunction: preserve metadata 2021-04-30 14:52:25 +02:00
Alessandro Di Federico 96a3cb83d3 Merge branch 'feature/function-tags' 2021-04-23 09:37:26 +02:00
Alessandro Di Federico 53f6328507 Introduce PromoteCSVs
This commit takes out of EnforceABI the part taking care of creating
wrappers for calls to helpers and promoting CSV to local variables.
This decoupling, enables to run -promote-csvs multiple times, for
instance after inlining.
2021-04-22 18:07:24 +02:00
Alessandro Di Federico 2e9c2ee275 Introduce FunctionTags
FunctionTags goal is to solve the long-standing problem of identifying
what type of function are we dealing with. Is it a lifted function? An
helper?

Now we have a sane way to determine this using Metadata and a proper
API.
2021-04-22 18:07:24 +02:00
Alessandro Di Federico e166ccf860 Merge branch 'feature/llvm-11-preparation' 2021-04-22 18:06:55 +02:00
Alessandro Di Federico 2ea5723a53 s/getCalledValue/getCalledOperand/g 2021-04-22 18:06:27 +02:00
Alessandro Di Federico aeb81c4218 Don't implicitly use StringRef as std::string 2021-04-22 18:06:27 +02:00
Alessandro Di Federico d6df9b682f Use MaybeAlign 2021-04-22 18:06:27 +02:00
Alessandro Di Federico bd3e048647 CPUStateAccessFixer: do not call delete directly 2021-04-22 18:06:27 +02:00
Alessandro Di Federico e92cbd91a1 LoadInst::LoadInst: pass pointee type 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 93ef716311 Module::getFunction returns Function * 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 90c93bfc26 Do not include PassSupport.h directly 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 1e8c43b1d5 PCH::store: pass IRBuilder by reference 2021-04-22 18:06:27 +02:00
Alessandro Di Federico fee270b64e Minor changes 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 0fcaf7f065 Merge branch 'feature/improve-performance' 2021-04-22 18:06:09 +02:00
Alessandro Di Federico 3ce9acf198 AVI: ignore function calls
This commit further reduces the time spent in AVI by considering all the
function calls as indirect. In fact, we currently don't handle indirect
jumps whose target is affected by computation happening before a
function call.
2021-04-22 18:05:39 +02:00
Alessandro Di Federico 33fbcd7ac2 AVI: stop backward exploration at dispatcher
This commit greatly improves the performance by ensuring that, when
computing the set of nodes we want to consider for AVI, we do not
traverse the dispatcher.

Doing so, means including *a lot* of irrelevant nodes and wasting a lot
of computation, since the CFG usually is not influenced by stuff
happening before an indirect jump.

In at least a situation the speedup is in the order of 20x, however this
depends on the size of the binary, since traversing the dispatcher means
including all the binary in the computations (as opposed to just the set
of blocks involved in the dataflow to compute a certain expression).
2021-04-22 18:05:39 +02:00
Alessandro Di Federico 84a4aef1ee nodesBetween: introduce ignore list 2021-04-22 18:05:39 +02:00
Alessandro Di Federico a27ee2faa6 Merge branch 'feature/prepare-helpers-inlining' 2021-04-22 18:05:10 +02:00
Alessandro Di Federico 0e21755eb0 Handle more count-leading-zeros helpers 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 618dbf3673 s/CSVsUsedByHelperCall/CSVsUsage/g 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 8c27f2bfcd OpaqueFunctionsPool: enumeration and registration 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 694b76a8e2 GenericGraph: propagate graph properties to nodes 2021-04-22 18:03:53 +02:00
Alessandro Di Federico e3157ffdd4 GenericGraph: initialize EntryNode 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 2a93ef2257 IRHelpers: introduce callers() 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 4f7be5a966 IRHelpers: generalize getContext to GlobalObjects 2021-04-22 18:03:53 +02:00
Alessandro Di Federico b29fc4c59c Ignore nulls in revng.csvs 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 02f3bb4f88 QEMU helpers no longer have optnone
QEMU helpers are compiled with -O0. This led the functions in the QEMU
helper module to have the `optnone` attribute, preventing any
optimization.

This has now been fixed on the QEMU side with the following flags:

    clang -Xclang -disable-O0-optnone
2021-04-22 18:03:53 +02:00
Alessandro Di Federico f5e8ac21c0 Merge branch 'feature/invoke-isolated-functions' 2021-04-22 18:02:57 +02:00
Alessandro Di Federico 651282a85a Introduce constructors
Isolated functions return structs. These structs used to be constructed
using `IRBuilder::CreateAggregateRet`, which is implemented using
`insertvalue` instructions. However, this approach led to ugly
decompiled code.

This commit introduces "constructor" functions that can be easily
pattern matched down the pipeline.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico 2b9cbb98ec Introduce --invoke-isolated-functions
This commit ensures that FunctionIsolation and EnforceABI do only
thing. This means that they no longer modify `root`.

Instead, we have a new pass, `invoke-isolated-functions` that needs to
be run after them and replaces the entry point of the functions with
invokes to the isolated functions, possibly with the appropriate
arguments.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico 081809ec38 Adopt EliminateUnreachableBlocks 2021-04-22 14:45:52 +02:00
Alessandro Di Federico c11065c7fd scripts/revng: handle same library multiple times
The `revng` script looks in several paths for analysis
libraries. However, before this commit, in case multiple versions of the
same library were available, you'd get unpredictable results.

This commit ensures that each library is considered at most once, in the
right order.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico 71044a9277 Drop setNoInline from invokes
This is no longer necessary, since we now use invoke instructions
properly and it's no longer possible to demote them to calls.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico 40ecee6482 Make SA tests more deterministic
When we compare StackAnalysis test results, the order in which things
appear in the JSON is relevant. However, the output was
non-deterministic due to a `std::map` using a pointer as key.

This commit improves the situation by sorting the elements by name
before dumping them in JSON.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico 45ee99d5de Merge branch 'feature/model-new-pass-manager' 2021-03-16 11:57:44 +01:00
Alessandro Di Federico 9171452342 Test instantiation of passes in new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico b25c43705c SerializeModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico c2d6631216 LoadModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico ae0a92d7e1 SymbolType::fromELF: do not abort 2021-03-16 11:36:32 +01:00
Alessandro Di Federico 1e6230b46c scripts/revng: drop print_help 2021-03-16 11:36:32 +01:00
Alessandro Di Federico 830ef23fe8 Whitespace changes 2021-03-16 11:36:32 +01:00
Alessandro Di Federico 58d0509909 scripts/revng: re-engineer option parsing
We now employ `argparse` subparsers.

This commit also fixes a bug involving global options with an argument
(such as `--prefix`) that led the argument to be interpreted as the
subcommand.
2021-03-10 12:29:25 +01:00
Alessandro Di Federico 8cee47f8a7 Merge branch 'feature/improve-cfg-identification' 2021-03-08 10:45:30 +01:00
Alessandro Di Federico e51145ec99 script/revng: introduce --prefix
`--prefix` enables projects using revng to easily and correctly employ
libraries available in build directories organized in a install
tree-like fashion.
2021-03-08 10:37:32 +01:00
Alessandro Di Federico 2c3df7068e revng-lift: keep harvesting upon new CFG edges
We used to stop the harvesting process when the harvesting process was
no longer able to identify new jump targets, even if new CFG edges have
been identified.

This approach prevented to discover additional parts of the CFG thanks
to the increased accuracy gained by a more accurate CFG. This effect is
particularly visible when we have jump tables that can be reached only
through other jump tables.
2021-03-08 10:15:50 +01:00