Commit Graph

6113 Commits

Author SHA1 Message Date
Antonio Frighetto c223b0aadc Fix end address in EFA tests 2022-04-05 15:37:57 +02:00
Antonio Frighetto 9980fc8c67 EFA: support dynamic function calls
EarlyFunctionAnalysis now can handle calls to
dynamically linked functions.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 499a837aac EFA: take a const model in Analyzer constructor
EarlyFunctionAnalysis now takes a `const TupleTree<model::Binary> &`
as part of `Analyzer` constructor, `finalizeModel` method excepted,
since it needs to write into the model.
2022-04-05 15:37:57 +02:00
Antonio Frighetto d6a1611c0a EFA: full ABI analysis or CFG collection only
EarlyFunctionAnalysis now can be invoked to schedule a full
ABI analysis over the collected functions via `--detect-abi`
option, or it can limit itself to simply recover the CFG and
serialize it onto the LLVM IR via `--collect-cfg` option.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 20cdfe668a EFA: take the control-flow graph out of the model
The control-flow graph and all its hierarchy components
have been moved from `model` to `efa`. The CFG is now
serialized onto the LLVM IR module as a metadata.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 98b79766be EFA: initialize cache by loading from model
The results of the model are loaded into the EarlyFunctionAnalysis
cache, and only those functions which are not in the model have
an EarlyFunctionAnalysis scheduled. The model is updated appropriately.
2022-04-05 15:37:57 +02:00
Antonio Frighetto ddc7fede5a EFA: optimize cross-call site propagation
Take advantage of directly iterating over the call-sites of a
function and perform the cross-call site merge, instead of
iterating over all the functions for each function.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 08b790329a EFA: fix end address of a jump target
EarlyFunctionAnalysis was considering jump targets as part of the
current basic block, thus computing the final address erroneously.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 12d8b1f222 EFA: remove reference template parameter
Code simplification to lighten the syntax.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 31926b7fe1 EFA: fix results on ABIAnalysis::dump method 2022-04-05 15:37:57 +02:00
Antonio Frighetto dad721941e JTM: set symbol name to OriginalName in newpc 2022-04-05 15:37:57 +02:00
Antonio Frighetto cbe1891ec1 Revise isolate-translate.yml opt pipeline 2022-04-05 15:37:57 +02:00
Antonio Frighetto aae31a3a05 Introduce function entry-points collection passes
The collection of the function entry-points has now been separated
from EarlyFunctionAnalysis into two distinct passes: the first one,
which collects functions which are in call-sites of a direct call,
and the second one which collects code pointers in `.rodata` (e.g.,
function pointers, vtables; jump-tables are possibly skipped).
2022-04-05 15:37:57 +02:00
Antonio Frighetto c42909f2f2 FunctionIsolation: relax boundaries handling
FunctionIsolation used to expect the model to adhere too much to what
is on the IR. We relax some assumptions, particularly: 1) if there is
a leftover direct boundary, `IndirectBoundary` is set to it regardless;
2) in `handleDirectBoundary`, the actual successors of a block should
include all those in the model, however, we permit extra successors,
if they exist.
2022-04-05 15:37:57 +02:00
Antonio Frighetto 5848063b66 TupleTree: make const TupleTree& behave as such
A logic issue was addressed with improved state management.
2022-04-05 15:37:57 +02:00
Antonio Frighetto c5b3fc4405 Rename ABIRegisters to ABICSVs 2022-04-05 15:37:57 +02:00
Antonio Frighetto 7ad5772c55 Move revng/ABIAnalyses/Common.h in EFA 2022-04-05 15:37:57 +02:00
Antonio Frighetto bb7102f647 Move old tests to EarlyFunctionAnalysis 2022-04-05 15:37:57 +02:00
Antonio Frighetto 7ace65adad Drop old CFEP notation 2022-04-05 15:37:57 +02:00
Antonio Frighetto 93cc2a5356 Drop Dump/CollectCFG.cpp
Unmaintained code has been removed.
2022-04-05 15:37:56 +02:00
Alessandro Di Federico f6c9b04c81 Adopt clang-tidy: readability-identifier-naming 2022-04-04 21:15:52 +02:00
Pietro Fezzardi 2844af4aef CMakeLists.txt: drop -Wl,--no-undefined
This is now implicitly added by orchestra configuration
2022-04-01 15:01:17 +02:00
Alessandro Di Federico 7dca2e78e0 Adopt new FunctionTags::Tag API 2022-03-31 16:41:30 +02:00
Pietro Fezzardi 58cdd814de MakeModelGEP: fix scoring for array accesses
This commit relaxes some assertions related to DLA, that were too strict
for general type systems not generated by DLA, and fixes the scoring of
the best access to select ModelGEPs.
2022-03-31 16:21:12 +02:00
Alessandro Di Federico 5576bfe86a EFA: add required libraries 2022-03-31 14:35:56 +02:00
Alessandro Di Federico dc897c7bbf Merge branch 'feature/hierarchical-function-tags' 2022-03-31 14:24:44 +02:00
Alessandro Di Federico 1a2a729e92 Rework FunctionTags::Tag 2022-03-31 12:51:24 +02:00
Alessandro Di Federico 30febba0ab mv revng/{Pipeline,Support}/DynamicHierarchy.h 2022-03-31 12:50:12 +02:00
Alvise de Faveri 8230d91da7 Add RemoveExtractValues and RestoreExtractValues
* RemoveExtractValues transforms every `extractvalue` instruction
  into an opaque call. This prevents the optimization pipeline from
  moving around and optimizing `extractvalue`s, since they have a
  particular meaning in our IR
* RestoreExtractValues transforms such opaque calls back to regular
  `extractvalue`s at the end of the pipeline
2022-03-31 10:49:13 +02:00
Pietro Fezzardi ddf6c23be6 Migrate AddressOf to OpaqueFunctionsPool 2022-03-31 10:36:57 +02:00
Pietro Fezzardi fa9627c8e7 Restructure CMakeLists.txt 2022-03-31 10:36:57 +02:00
Pietro Fezzardi de033b50f2 RegisterLLVMPass.h: add missing include
Missing `#include "revng/Pipeline/Loader.h"` causes compilation error
when calling `Loader.registerLLVMPass<LLVMPass>(Name);`.

This is a problem since whoever includes `RegisterLLVMPass.h` should
include `Loader.h` **before** `RegisterLLVMPass.h` to compile without
errors. This is subject to breakage if `Loader.h` ever changes name and
`clang-format` starts reordering the include **after**
`RegisterLLVMPass.h`.

This commit inlcudes `Loader.h` directly in `RegisterLLVMPass.h` to fix
the root cause.
2022-03-30 19:42:22 +02:00
Alessandro Di Federico 767c43f113 Merge branch 'feature/type-based-functions-pool-init' 2022-03-30 19:41:51 +02:00
Pietro Fezzardi 32cf3fc3cf OpaqueFunctionsPool: remove redundant LLVMContext 2022-03-30 17:21:48 +02:00
Pietro Fezzardi 918bf8d2b1 Use new OpaqueFunctionsPool init methods 2022-03-30 17:21:48 +02:00
Pietro Fezzardi 838c5f7319 Load type-based OpaqueFunctionsPool from Module
This commit adds two method for OpaqueFunctionsPool that use
a pointer to `llvm::Type` (or a class derived from `llvm::Type`) as key.

Both methods are used to initialize the pool with pre-existing functions
inside an `llvm::Module` that match a specific `FunctionTags::Tag`:
- `initializeFromReturnType` uses the return `llvm::Type` of the
  function as key in the pool
- `initializeFromNthArgType` takes an additional argument which is an
  index N, and uses the return `llvm::Type` of the N-th argument as a
  key in the pool

These methods are useful for avoiding unnecessary proliferation of
opaque functions in an `llvm::Module`, re-using the existing ones
instead if they are already present.
2022-03-30 17:21:48 +02:00
Pietro Fezzardi b27432fcbd Move NotVoid and DerivesFrom to ADT/Concepts.h
since they can be useful elsewhere.
2022-03-30 17:11:40 +02:00
Pietro Fezzardi b4c733ab57 Move Concepts.h into include/ADT for better reuse 2022-03-30 17:09:24 +02:00
Pietro Fezzardi 18f5d7577f Move copy_to_build_and_install to Common.cmake
This enables using this handy helper function also in revng-c.
2022-03-30 14:39:29 +02:00
Pietro Fezzardi b0ce5466d6 MakeModelGEP: fix off-by-minus error in assertion 2022-03-28 17:58:42 +02:00
Alessandro Di Federico 9573946a92 Merge branch 'feature/abi-stack-arguments' 2022-03-28 16:16:26 +02:00
Ivan Krysak c7fe3b0a42 Improve ABI testing artifact naming 2022-03-28 15:43:34 +02:00
Ivan Krysak 2313335feb abi-verify: move to a byte array-oriented approach 2022-03-28 15:43:34 +02:00
Ivan Krysak 59b5d3dce4 Add runtime ABI trait access 2022-03-28 15:43:34 +02:00
Ivan Krysak a10415fd0b Make the function layout argument type aware 2022-03-28 15:43:34 +02:00
Ivan Krysak a7617f3567 Describe the ABI testing utilities 2022-03-28 15:43:32 +02:00
Ivan Krysak 1b03adca5e Make function type convertions self-sufficient 2022-03-28 15:38:04 +02:00
Ivan Krysak 23173aef29 Add a specialized model comparison tool
It fixes mistreated RFT stack arguments before relying on model passes
for the comparison itself.
2022-03-28 15:38:04 +02:00
Ivan Krysak f614a8cf7f Implement ABI SystemV_x86_64 stack support 2022-03-28 15:38:04 +02:00
Ivan Krysak 974229b171 Optimize the ABI testing script 2022-03-28 15:38:01 +02:00