Commit Graph

53 Commits

Author SHA1 Message Date
Ivan Krysak 79964eac74 Avoid ' misuse in error messages and comments 2025-04-17 16:41:21 +02:00
Ivan Krysak e1c8c370f7 Lift: adopt helper registry 2025-04-17 11:19:17 +03:00
Ivan Krysak aa15d8ca21 Standardize abort-like function usage 2025-04-17 11:19:17 +03:00
Ivan Krysak 3edb6cbb9b Minor improvements 2025-04-15 16:35:42 +03:00
Alessandro Di Federico 62b518b381 Lift: limit instcombine to one iteration 2025-02-20 17:58:00 +01:00
Ivan Krysak 705e4a5955 auto [...] -> auto &&[...] 2025-02-13 13:10:51 +02:00
Alessandro Di Federico 2128a80cc8 Preserve metadata after Function::deleteBody
Also, introduce and adopt a simple helper class to get this right.
2025-01-28 12:19:16 +01:00
Alessandro Di Federico c1cbb4e9a0 Initialize pointers to nullptr 2024-09-27 12:07:17 +02:00
Alessandro Di Federico 0126f0ce9b CodeGenerator: use VirtualSize when ptc.mmaping 2024-09-27 12:07:16 +02:00
Alessandro Di Federico 744184c90c Do not use CallBase::getCalledFunction
Use our wrapper, which does not return nullptr if the `FunctionType`s do
not match.
2024-08-07 16:07:59 +02:00
Massimo Fioravanti 43349943a7 Stop serializing the model in the IR 2024-06-20 09:57:36 +02:00
Alessandro Di Federico e64eee9402 CodeGenerator: handle partially valid instructions
Sometimes we have instructions that are, say, two bytes long but only
one of the two bytes are invalid (because they end up out of the
segment).
2024-05-15 13:19:42 +02:00
Alessandro Di Federico a04ccb6883 CodeGenerator: relax check on entry point 2024-02-09 10:04:19 +01:00
Alessandro Di Federico f81851c36b CodeGenerator: do not tag LLVM intrinsics 2024-02-09 10:04:19 +01:00
Ivan Krysak 77b1acaf00 Prefer uint64_t to size_t wherever relevant 2024-01-29 11:57:54 +02:00
Alessandro Di Federico 14525d91f5 Adopt llvm::Task 2023-08-01 10:51:16 +02:00
Ivan Krysak 7d235f4fd0 Enforce licence header consistency
Also do some basic cleanup: capitalize first letters, add `.`
at the end of the sentences, and so on.
2023-07-03 15:23:10 +00:00
Ivan Krysak 9f1d9fd5d0 Use Container::contains() where appropriate 2023-07-02 15:06:11 +00:00
Alessandro Di Federico 170749b0aa Introduce revng::verify 2023-04-28 14:04:31 +02:00
Alessandro Di Federico f7f47ceac6 VariableManager: drop autodetection of ${ARCH}CPU 2023-04-08 08:42:24 +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 26765f3d84 Drop usages of getBasicBlockList 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 06f9bca598 Adopt {add,remove}FnAttribute 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
Alessandro Di Federico dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +02: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
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Alessandro Di Federico 712585be48 CodeGenerator: handle PTC translation failure 2022-08-31 18:07:47 +02:00
Alessandro Di Federico 5f49437393 CodeGenerator: invoke peek post newpc creation 2022-08-03 18:35:57 +02:00
Djordje Todorovic a36e22729f Model: Add PDB support 2022-07-28 14:52:50 +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 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
Alessandro Di Federico 0793e4afcb Turn lifting into a pass 2022-03-11 15:37:12 +01:00
Alessandro Di Federico ee0b8f44c1 Introduce BinaryImporter
This is a big step to split revng-lift in two parts: one that only
writes the model and one that actually lifts to LLVM IR.

* Introduce `revng import binary`
* Split off `BinaryFile.h`
* Drop `revng.h`
* `GeneratedCodeBasicInfo`: use model
* Reduce role of `GeneratedCodeBasicInfo` in favor of
  `model::Architecture` and `model::Register` methods
* `CodeGenerator`: adopt `RawBinaryView` and model
* `JumpTargetManager`: adopt `RawBinaryView` and model
* `ExternalJumpsHandler`: adopt model
* `InstructionTranslator`: discard `Architecture` in favor of
  `EndianessMismatch`
* Many other changes
2022-03-08 15:15:24 +01:00
Alessandro Di Federico 60cce26768 Support streaming llvm::Errors to Loggers 2022-03-08 15:04:34 +01:00
Alessandro Di Federico 0a5d2c04a7 Rework LoadModelPass 2022-03-08 15:04:34 +01:00
Alessandro Di Federico a88a9e52c3 Improve model::Segment 2022-03-08 13:06:47 +01:00
Alessandro Di Federico 39ace7dc56 mv revng{DwarfImporter,ModelImporterDwarf} 2022-03-08 12:25:47 +01:00
Alessandro Di Federico c1ed018786 Fix a revng_assert meant to be a revng_abort 2022-03-08 12:25:22 +01:00
Ivan Krysak 242b885a78 Remove obsolete ABI utilities 2022-02-14 13:35:37 +01:00
Ivan Krysak 68129c9221 Add model::Binary::DefaultABI field 2022-02-14 13:35:36 +01:00
Massimo Fioravanti 6f0d0c4f9d CodeGenerator: accept an external model 2022-02-07 22:24:39 +01:00
Alessandro Di Federico d0bb3d4c2c CodeGenerator.cpp: use OriginalName for symbols 2022-01-27 11:51:03 +01:00
Alessandro Di Federico 445066bd0a CodeGenerator.cpp: posticipate DWARF import
This way we apply the optimization passes.
2022-01-27 11:51:03 +01:00
Alessandro Di Federico 680924b643 CodeGenerator.cpp: drop some outdated assertions
Drop some outdated checks for `model::Binary::ImportedDynamicFunctions`
being sorted.
2022-01-27 11:51:03 +01:00
Filippo Cremonese fbeee896e1 Rename model::abi -> model::ABI 2022-01-10 10:31:27 +01:00
Alessandro Di Federico cfb47157b9 clang-tidy: readability-identifier-naming
This commit fixes all the non-compliance with our preliminary clang-tidy
configuration, which will be merged soon.
2022-01-07 09:18:05 +01:00
Alessandro Di Federico 6073133545 CodeGenerator: drop IR emission duties 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 27b553f09e CodeGenerator: stop emitting .li.csv and .need.csv 2021-12-22 17:47:54 +01:00