Commit Graph

869 Commits

Author SHA1 Message Date
Kacper Kołodziej 23c8c199a1 Rename getStrByAddress to getStringByAddress
We don't use abbreviations in names.
2023-03-29 16:37:34 +02:00
Pietro Fezzardi 022aeb0df3 RawBinaryView: add getStrByAddress method
This method is similar to `getByAddress`, but it returns an
`llvm::StringRef`.

It is intended for those users that need to manipulate the bytes as
strings. In those cases, the `llvm::ArrayRef<uint8_t>` returned by
`getByAddress` is not suitable, because it triggers warnings due to
`uint8_t` not being the same as `char`.
2023-03-29 16:37:34 +02:00
Kacper Kołodziej b36bd3bd6c Add RawBinaryView::isReadOnly method
isReadOnly returns true if segment which contains region defined with
 MetaAddress and size is not writable.
2023-03-29 16:37:34 +02:00
Giacomo Vercesi c7d13fd176 PipelineC: fix model verification clause
In the previous implementation of Model.verify an llvm::Error was
returned. Some call sites retained the logic associated with it. Fix
these with the correct logic.
Also fix an instance of `verify` that was missing an assert.
2023-03-20 16:20:06 +01:00
Giacomo Vercesi 3b94dfae4b PipelineC: rework rp_error data type
Drop the use of unique_ptr within the rp_error data type and instead use
std::monostate. Also fix the functions to allow the use of `nullptr` as
the error parameter
2023-03-20 16:08:04 +01:00
Ivan Krysak 64856306c4 BinaryImporter: rework command line interface 2023-03-15 10:19:03 +01:00
Ivan Krysak e84c76019a ABI: introduce an additional definition option
The new option is `NoRegisterArgumentsCanComeAfterStackOnes`
If it's set to `true`, then no register argument can follow any stack
argument under the said abi, otherwise such "shuffling" of arguments
is allowed.
2023-03-15 10:19:03 +01:00
Ivan Krysak 4d21a88777 Model: remove an obsolete function conversion pass 2023-03-15 10:19:03 +01:00
Ivan Krysak fba30712cc ABI: introduce abi::FunctionType::filterTypes 2023-03-15 10:19:03 +01:00
Ivan Krysak a0adafeab0 ABI: take advantage of register state deductions
This makes the conversions more robust, since everything can rely on
the same tools for filling in missing registers and ordering them based
on the ABI requirements.
2023-03-15 10:19:03 +01:00
Ivan Krysak 1d1003b7e5 ABI: introduce TypeBucket helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 8a1d62728d ABI: remove constexpr abi trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 30b9234a04 abi::Definition: introduce a padding helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 89b3def533 ABI: move RegisterOrder onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak 9e393578c9 ABI: move state deduction onto the runtime trait 2023-03-15 10:19:02 +01:00
Ivan Krysak ce0d39a9a6 Model: document model::Type::size() 2023-03-15 10:19:02 +01:00
Ivan Krysak 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 769e5c1cbe ABI: add a natural alignment calculation helper 2023-03-15 10:19:02 +01:00
Ivan Krysak 8b675e131e ABI: introduce runtime abi definition 2023-03-15 10:19:02 +01:00
Ivan Krysak 395191cdf1 ABI: use replaceReferencesIf when updating types 2023-03-15 10:19:02 +01:00
Ivan Krysak bcca3ac8b7 TupleTree: introduce replaceReferencesIf 2023-03-15 10:19:02 +01:00
Ivan Krysak 9eb55f363b STLExtras: introduce some c++20 invocable concepts 2023-03-15 10:19:02 +01:00
Ivan Krysak 01a05e2037 ABI: separate convertions based on the direction 2023-03-15 10:19:02 +01:00
Ivan Krysak 2f3128cb43 ABI: separate reused helpers into Support.h 2023-03-15 10:19:02 +01:00
Ivan Krysak 8521f6bedc YAML: enable manual [de]serialization of enums 2023-03-15 10:19:02 +01:00
Ivan Krysak eb67826da6 PathList: accept non-owning strings as arguments 2023-03-15 10:19:02 +01:00
Ivan Krysak 75feff6186 model::Register: introduce isUsedInArchitecture 2023-03-15 10:19:02 +01:00
Ivan Krysak 058807ca00 model::Register: rename getArchitecture
The new name is `getReferenceArchitecture`
2023-03-15 10:19:02 +01:00
Ivan Krysak 9148f70b24 model::Register::getSize: leave a TODO 2023-03-15 10:19:02 +01:00
Ivan Krysak 7442bdc4a9 Model: introduce model::ABI::getPointerSize 2023-03-15 10:19:02 +01:00
Ivan Krysak c45b7778c1 Model: introduce copyMetadata and moveMetadata 2023-03-15 10:19:02 +01:00
Ivan Krysak 3c0c49c785 Model: add ABI::getRegisterArchitecture 2023-03-15 10:19:02 +01:00
Ivan Krysak 07837d9b9b Model: add model::Binary::recordNewTypes 2023-03-15 10:19:02 +01:00
Ivan Krysak b0e481cdef Model: add model::Binary::makeType 2023-03-15 10:19:02 +01:00
Ivan Krysak 69c292102d Pipeline: improve InvokableWrapperImpl::dump() 2023-03-15 10:19:02 +01:00
Ivan Krysak 3904e525b0 SortedVector: improve new element insertion
This introduces `emplace` and `emplace_or_assign` members
allowing population of the container without copying values in.

It also reworks the batch insertion. On top of adding the ability
to move the elements in (without making a copy) and constructing
them in place, it also makes the non-assign version of the inserter
a lot safer by explicitly asserting the fact that while it was
in use no duplicates were added to the vector. Before now,
the duplicates were just silently removed from the container.

It also optimizes the batch insertion somewhat by using non-stable
`std::sort` for unique case as well as replacing `std::unique`
invocation with `std::find_adjacent`.
2023-03-15 10:19:02 +01:00
Ivan Krysak 64a4672f32 STLExtras: introduce ranges::views::as_rvalue 2023-03-15 10:19:01 +01:00
Ivan Krysak a06d9fedbd STLExtras: extend revng::find family 2023-03-15 10:19:01 +01:00
Ivan Krysak e79870e7c6 STLExtras: rework the skip range modifier
Note that all this is going to be obsolete once we can start using
the compiler with c++20 `views` support.
2023-03-15 10:19:01 +01:00
Ivan Krysak 3687869795 Model: make AddPrimitiveTypes a pure analysis 2023-03-15 10:19:01 +01:00
Ivan Krysak 03be19fab8 Pipeline: fix pure (model only) analysis support
Because of a missing function overload, no container-less analysis
could have been created. This adds the said overload.
2023-03-15 10:19:01 +01:00
Giacomo Vercesi 15da250710 api/daemon: fix single analysis handling
* Let GraphQL accept zero or more parameters for analyses
* Handle the general case of analyses using zero or more containers with
  a variable ammount of targets
2023-03-15 10:19:01 +01:00
Ivan Krysak 11c0d7f02e Stop using \brief doxygen command 2023-03-15 10:19:01 +01:00
Ivan Krysak 0b1aaeaede Minor improvements 2023-03-15 10:19:01 +01:00
Alessandro Di Federico 6b166bf0b9 Import TaggedFunctionPass 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 09541be398 getUniqueString: do not rely on named metadata
`getUniqueString` returns a dedup'd char array `GlobalVariable` given a
string. We used to rely on named metadata to dedup them. However, this
lead to issues with `LLVMContainer` cloning and linking.

The new implementation uses the name of the variable as the
de-decuplication key, circumventing the problem entirely and improving
performance.
2023-03-13 22:53:44 +01:00
Alessandro Di Federico 6f47231695 LLVMContainer: pruneDICompileUnits pre linking 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 8d813e169a LLVMContainer: drop certain named MD pre linking 2023-03-13 22:53:44 +01:00
Alessandro Di Federico 4353beff22 LLVMContainer: fix how we adjust linkage
We used to turn `internal` linkage to the equivalent of C++'s inline.
We need to do the same for `private`. If we don't do this, the number of
`private` variables grows exponentially.
2023-03-13 22:53:44 +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