Commit Graph

249 Commits

Author SHA1 Message Date
Alessandro Di Federico 1d8382187c Dismiss ConstantStringsPool, use getUniqueString 2023-04-28 14:04:32 +02:00
Alessandro Di Federico 170749b0aa Introduce revng::verify 2023-04-28 14:04:31 +02:00
Alessandro Di Federico bce3555285 Drop CallToLifted tag
This commit drops the `CallToLifted` tag in favor of a
`getCallToIsolatedFunction` function which checks if the call has the
`IsolatedFunction` tag. The function also assumes that indirect calls
are calls to lifted functions.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico b5607efce0 struct_initializer: mark as pure 2023-04-13 18:11:48 +02:00
Alessandro Di Federico 98b92a5b01 Prevent merging calls to isolated functions
SimplifyCFG with instruction sinking enabled sometimes can merge two
call sites that are identical at LLVM IR level, but originally come from
two distinct addresses in the original binary.

The nomerge attribute prevents this type of problematic deduplication.
2023-04-13 18:11:48 +02:00
Alessandro Di Federico 79d9011b95 InlineHelpers: drop !dbg post-inlining 2023-04-13 18:11:48 +02:00
Alessandro Di Federico ae871f5062 Adopt setOnlyReadsMemory 2023-04-08 08:42:24 +02:00
Alessandro Di Federico e131817334 Drop usage of Type::getPointerElementType 2023-04-08 08:42:24 +02:00
Alessandro Di Federico a99d54457b Drop usages of getInstList 2023-04-08 08:42:24 +02:00
Alessandro Di Federico aa6a60c5b8 Adopt new InlineFunction prototype 2023-04-08 08:42:24 +02:00
Alessandro Di Federico d2caa1fad0 Make CreateLoad usages opaque pointers-compatible 2023-04-08 08:42:24 +02:00
Ivan Krysak 01a05e2037 ABI: separate convertions based on the direction 2023-03-15 10:19:02 +01:00
Alessandro Di Federico 927f5b38be PromoteCSVs/EnforceABI: handle declarations
PromoteCSVs and EnforceABI were not handling declarated functions
properly, leading to issues downstream.
2023-03-13 22:53:44 +01:00
Alessandro Di Federico 54e8393cb8 Minor changes 2023-03-13 22:53:44 +01:00
Alessandro Di Federico bd61df1ddd PromoteCSVs::getUsedCSVs: fix non-helpers 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 9efe5e1366 PromoteCSVs: rename metadata to revng.abi_register 2023-02-23 14:51:10 +01:00
Alessandro Di Federico f68b7866b3 Introduce BasicBlockID
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.

Apart from this, the commit also does the following:

* It drops representing `MetaAddress`es a `structs` in the IR. This created
  several issues related to ABI. We now represent them as strings.

* It defines more functions in `support.h`, instead of defining prototypes
  by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
  and `raise_exception_helper`. We also introduce a C "constructor" for
  `PlainMetaAddress`.

* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
  was supposed to be put on a diet since a long time.  Specifically,
  many jump target related methods have been moved to free functions in
  `IRHelpers.h`.  Also `GCBI::getSuccessors` has been pushed into its
  only user, `PruneRetSuccessors`, to prevent further usage of a
  deprecated API. In the future, it would be nice to drop it entirely.

* It introduces `efa::BasicBlock::InlinedFrom`.

* Introduce an enum to represent named argument indices for `newpc`.
  This enables us to more effectively manipulate its argument list.

* It improves the verification and error reporting for
  `efa::FunctionMetadata`.

* Update tests.

This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
2023-02-23 14:51:10 +01:00
Alessandro Di Federico d3f6d43ffe PromoteCSV: tag init_ functions with register
This enables downstream passes to selectively purge calls to `init_`
functions.
2023-02-23 08:30:22 +01:00
Antonio Frighetto f73b9876fa FunctionIsolation: execute CollectCFG earlier
This change makes sure that CollectCFG is always intertwined
with FunctionIsolation, as it needs to run before the latter
executed. To avoid possible rearrangements on the pipeline
in the future, CollectCFG pass is now registered within FI.
2023-02-06 09:37:23 +01:00
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Ivan Krysak 855999f5f0 Layout: add support for multiple return values 2022-11-30 15:06:54 +01:00
Alessandro Di Federico 009c0c2434 flake8: disable R505 (else after return statement) 2022-11-22 15:10:52 +01:00
Massimo Fioravanti 0bfb73fe95 FunctionMetadata: introduce cache
FunctionMetadata was being deserialized every time they were
inspected. This commit introduces a cache structure to prevent this
excessive deserializations.
2022-11-22 14:15:00 +01:00
Giacomo Vercesi d185fc80ac Rank: fix RankConvertibleTo with RootRank
RankConvertibleTo would be erroneously fail when used with a RootRank
either in the From or To template parameter.
2022-11-11 13:43:55 +01:00
Massimo Fioravanti fa30486ce0 Outliner: create extractor cache once 2022-11-10 19:41:42 +01:00
Massimo Fioravanti d55aa9b9e6 Pipeline: remove * from targets
Now * is just a pipeline frontend shorthand.
2022-10-20 14:20:12 +02:00
Alessandro Di Federico 9dd0b139c0 PromoteCSVs: helpers no longer return structs
PromteCSVs creates wrappers around helpers. These helpers used to return
a struct in case the helper was changing a CSV.

In order to simplify the downstream pipeline, we now use out arguments
instead of returning a struct.
2022-09-29 10:53:47 +02:00
Alessandro Di Federico 8d4b3833ec InvokeIsolatedFunctions: adopt splitBasicBlockBefore 2022-09-26 18:10:12 +02:00
Massimo Fioravanti 633f49c1ef Introduce dedicated namespace for kinds and ranks 2022-08-29 14:44:53 +02:00
Massimo Fioravanti 96bd5835d8 revng-pipeline: rework file-to-container syntax 2022-08-10 09:49:24 +02:00
Alessandro Di Federico 1cf9a06009 EnforceABI: use read-only model 2022-08-08 13:55:36 +02:00
Alessandro Di Federico 6a6cd939db Rework EarlyFunctionAnalysis 2022-08-08 13:55:34 +02:00
Ivan Krysak 792da8151e Redesign the rank definition process 2022-08-05 19:58:57 +02:00
Ivan Krysak 65d1a016d4 Standardize concept naming across the codebase 2022-08-05 17:27:56 +03:00
Ivan Krysak 8305e020b0 Move ranks into their own namespace 2022-08-05 17:27:56 +03:00
Alessandro Di Federico add47a861a EnforceABI: use read-only model 2022-08-05 14:39:29 +02:00
Massimo Fioravanti 55fb87b268 PipelineC: introduce dead kinds
We need to prevent stub kinds used just to represent dead elements to be
displayed in the GUI and CL.
We do so by introducing a DeadKind which expands their targets to the
empty list.
2022-06-20 19:03:17 +02:00
Massimo Fioravanti f0a5ffe3b3 revng-pipeline: globals, extractOne and analyses 2022-05-24 08:58:48 +02:00
Alessandro Di Federico 3c2a7dd5f2 EnforceABI: in case of no prototype, use default 2022-04-29 17:57:49 +02:00
Alessandro Di Federico 305a6ba69c Isolate: use Attribute::NullPointerIsValid
This enables us to handle memory accesses at nullptr.
2022-04-29 17:57:49 +02:00
Alessandro Di Federico 0e907021e3 EnforceABI: preserve metadata
This is particularly useful for preserving `FunctionTag`s.
2022-04-29 17:57:49 +02:00
Alessandro Di Federico 2e933cde6b Dynamic functions: use OriginalName
`OriginalName` is the key.
2022-04-29 17:57:49 +02:00
Pietro Fezzardi a4dc1e52fd EnforceABI: add FunctionTags::ABIEnforced tag 2022-04-12 14:15:01 +02:00
Pietro Fezzardi 69d65956bf PromoteCSV: add FunctionTag::CSVsPromoted tag 2022-04-12 14:14:19 +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 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
Alessandro Di Federico 1a2a729e92 Rework FunctionTags::Tag 2022-03-31 12:51:24 +02:00
Pietro Fezzardi 918bf8d2b1 Use new OpaqueFunctionsPool init methods 2022-03-30 17:21:48 +02:00
Alessandro Di Federico 2b55d1df22 Adopt cmake-format 2022-03-17 18:52:18 +01:00
Alessandro Di Federico 00ce580362 Introduce EnforceABI and PromoteCSV pipes 2022-03-17 14:10:50 +01:00