Commit Graph

107 Commits

Author SHA1 Message Date
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
Alessandro Di Federico 9fb3b647a4 Introduce DropRootPass 2022-03-17 14:10:50 +01:00
Alessandro Di Federico fa3206b26d Rename Lifted tag to Isolated 2022-03-17 14:10:50 +01:00
Alessandro Di Federico 5e38805063 Rename detail namespaces into revng::detail 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 0a5d2c04a7 Rework LoadModelPass 2022-03-08 15:04:34 +01:00
Alvise de Faveri 0659e6b6a3 Model: Improve getCallSitePrototype() helper
1. Hoist the logic to retrieve a model CallEdge from an llvm::CallInst
   out of `getCallSitePrototype()`, in a separate `getCallEdge()`
   function.
2. Modify `getCallSitePrototype()` so that the parent function's type is
   optional.
2022-03-02 15:40:27 +01:00
Ivan Krysak d811321538 InvokeIsolatedFunctions: adopt Layout 2022-02-25 00:30:38 +01:00
Ivan Krysak f30ed88eb5 EnforceABI: adopt FunctionType::Layout 2022-02-25 00:30:27 +01:00
Ivan Krysak 541643afc3 Move function type conversion to librevngABI 2022-02-24 23:56:30 +01:00
Ivan Krysak 242b885a78 Remove obsolete ABI utilities 2022-02-14 13:35:37 +01:00
Alvise de Faveri 7593d4da23 PromoteCSVs: promote PC CSVs 2022-02-12 12:04:14 +01:00
Alvise de Faveri 812b73f2a2 Remove opaquepc()
We can set the PC to the expected value after each call instead
of creating an `opaquepc()` call.
2022-02-11 13:42:29 +01:00
Alessandro Di Federico e80d159944 revng-pipline: simplify Kinds.h 2022-02-08 17:44:33 +01:00
Massimo Fioravanti a8a8da3bae Introduce revng pipes
This commit imports all the revng pipes (and other support utilities) to
be used with `revng-pipeline`. In particular, the pipes necessary for
binary translations have been introduced.
2022-02-08 00:05:03 +01:00
Alessandro Di Federico 863652f480 Introduce OriginalName in the type system
The goal of `OriginalName` is to keep track of the original name of a
symbol upon import.

In future, this will also be used to promote it to `CustomName`.
2022-01-27 11:51:03 +01:00
Filippo Cremonese 74217b4fe5 Generate C++ model from YAML definition
Model classes are now described by a YAML document, which is used to
generate C++ headers containing classes and all the boilerplate
required for YAML serialization/deserialization, usage in
SortedVectors, etc. See the README in include/revng/Model for more
info.
2022-01-13 14:34:11 +01:00
Massimo Fioravanti 79d5ca1e27 Introduce FunctionTags::IsolatedRoot
This will be used by the revng-pipeline to tell apart a `root` calling
isolated functions from a regular one.
2022-01-05 14:45:01 +01:00
Alessandro Di Federico f97f8a880c Drop extra assertions related to debug info 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 7c050ee377 mv include/revng/{TypeShrinking,MFP}/SetLattices.h 2021-12-17 18:51:06 +01:00
Alessandro Di Federico 3e1e69e08f Introduce eraseFromParent 2021-12-17 18:50:08 +01:00
Alessandro Di Federico 4b6a557a19 Fix key issues in -promote-csv
The following bugs have been fixed:

* PromoteCSV no longer mixes `alloca` with other instructions, which is
  a convention in LLVM IR that some passes rely upon.
* Before this commit, we were detecting if *calls to CSV initializers*
  where already present in order to reuse them, but this was not right,
  we need to reuse the *alloca* instructions they are associated
  with. This commit does exaclty that.
2021-12-17 18:49:51 +01:00
Alessandro Di Federico 04633a21ca Tag call sites with CallToLifted 2021-12-17 18:49:26 +01:00
Alessandro Di Federico 9a60a5fd82 Expand IRHelpers
* New `getCallTo` overloads accepting `Function *`
* `setInsertPointToFirstNonAlloca`
* Various additional helpers for Load/StoreInst
* `changeFunctionType`
2021-12-17 18:48:36 +01:00
Alessandro Di Federico 1dbe474873 Whitespace fixes 2021-12-16 11:56:06 +01:00
Antonio Frighetto 10f45c593a Move StackAnalysis to EarlyFunctionAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto ffd5ac7f57 Drop old StackAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto cbd81e57d9 Improve MFP 2021-12-15 18:03:30 +01:00
Antonio Frighetto b5f87748eb PromoteCSVs: no wrapper for Marker and Exceptional 2021-12-15 18:03:30 +01:00
Antonio Frighetto 034618d228 FunctionIsolation: fix object passed by copy 2021-12-15 18:03:30 +01:00
Alessandro Di Federico 4401871489 FunctionIsolation: handle NoReturn attribute 2021-12-15 18:03:30 +01:00
Alvise de Faveri 267410ac43 Add Attribute::WillReturn to ReadOnly funcs
Without this attribute, newer versions of llvm are not able to
remove calls to `ReadOnly` functions whose return value is unused.

This is instead the expected behavior for the functions that are
generated by `revng` with the `ReadOnly` attribute.
2021-11-19 10:17:02 +01:00
Alessandro Di Federico eb2c3df925 Tag with MetaAddress functions and call sites 2021-10-21 15:02:00 +02:00
Alessandro Di Federico 8546a0c786 CallEdge: only indirect calls have a prototype 2021-10-21 15:01:59 +02:00
Alessandro Di Federico 3a3eea0cf5 Introduce support for dynamic functions 2021-10-21 15:01:19 +02:00
Alessandro Di Federico 0dfc81da41 Minor model improvements
* Introduce some documentation for the model.
* Improve the way enums are serialized/deserialized.
* Mark certain fields of model data structures as optional.
* introduces some error messages during model validation.
2021-10-18 20:44:58 +02:00
Alessandro Di Federico 06043b92c6 PromoteCSV: do not promote the stack pointer 2021-10-18 20:44:58 +02:00
Alessandro Di Federico e29c36cd51 Drop --disable-enforce-abi-safety-checks 2021-10-18 20:44:58 +02:00
Alessandro Di Federico 18cfbdbfe0 Whitespace and other minor changes 2021-10-18 12:39:21 +02:00
Alessandro Di Federico 6e4cd06095 Add LLVM libs for --no-undefined compliance 2021-09-01 16:40:56 +02:00
Alessandro Di Federico fd30d3de42 Import the model's type system
This commit introduces the type system of the model along with several
various other improvements to the model and its users.

* Introduce the type system.
* Introduce possibility to tag certain fields in the model as to be
  optional during YAML serialization.
* All the `Name` fields have been replaced in favor of `CustomName` plus
  a `name` method that will use `CustomName` if available, or an
  automatically generated name otherwise.
* Make TupleTreeReferences behavior more robust: now you either need to
  have a valid pointer to `Root` and a `Path` or be default constructed
  (`nullptr` for `Root` and an empty `Path`). Any other configuration is
  invalid.
* The type system introduces `RawFunctionType`: this superseds the
  previous way in which we were specifying arguments and return
  values. Users of such information have been updated accordingly.
2021-07-21 18:22:58 +02:00
Alessandro Di Federico 6d10581163 Whitespace and other minor changes 2021-07-15 13:30:25 +02:00
Pietro Fezzardi f0a6184ac0 Propagate DebugLoc on CallInst and InvokeInst
With llvm-12 thera are more stringent requirement on the propagation of
DebugLoc on CallInst and InvokeInst.
Various CallInst and InvokeInst created during lifting did not fulfill
these requirements, causing the Module to not verify() with llvm-12.

This commit fixes the problem, properly propagating the debug locations.
2021-06-14 23:04:02 +02:00