Commit Graph

2366 Commits

Author SHA1 Message Date
Pietro Fezzardi ca1fd101db Add opaque function to LLVM test helpers
This commits adds an opaque function that can be called by simple LLVM
IR snippets used in unit tests.
2023-04-06 14:25:18 +02:00
Pietro Fezzardi 7edc9eeecc Void instructions never needsTopScopeDeclarations 2023-04-06 12:01:48 +02:00
Pietro Fezzardi d7cfb96331 Improve hasSideEffects for llvm Intrinsics
Now a call to an llvm Intrinsic is detected has having side effects only
if it is not ReadNone nor ReadOnly.
2023-04-04 09:33:22 +02:00
Kacper Kołodziej 2445c5e740 MakeSegmentRefPass: emit cstringLiteral
This commit changes MakeSegmentRefPass so that it's now a ModulePass and
it uses the binary to detect integer constants that represent the
address of strings.
When it detects address of constant strings, instead of injecting calls
to SegmentRef, we now inject calls to cstringLiteral, so that we can
later emit them as inline string literals in C.

In segmentRef we use integer type meaning address in memory, so we
generate segmentRef function with non-pointer type. For cstringLiteral
function we need real pointer type of operand.

Save MetaAddress, size, offset and original type for every
cstringLiteral call in metadata as we do for segmentRef calls.

For cstringLiteral "revng.cstring_literal" metadata name is used.

StringLiteralPool needs tuple of address, size, offset and type to
keep distinct string decorator functions for each string. This tuple is
represented by StringLiteralPoolKey struct.

Pipe for MakeSegmentRefPass needs to be defined explicitly, because
additional wrapper passes are required in MakeSegmentRef:

 1. LoadModelWrapperPass
 2. LoadBinaryWrapperPass

MakeSegmentRefPass requires access to RawBinaryView to detect cstring
literals in binary.

Fix printed command in MakeSegmentRefPipe

This printed command might not work. @ale commented it will be replaced
with `revng pipe run-pipe` once we will have it.

Update IRHelpers to new revng API

Switch String and Namespace arguments in getUniqueString
2023-04-04 09:31:10 +02:00
Kacper Kołodziej f83cb94e1f Add StringLiteral tag and corresponding f. pool
StringLiteral tag will be used to mark cstring decorators in generated
IR.
2023-04-04 09:31:10 +02:00
Kacper Kołodziej e7bb7d09df Rename getStrByAddress to getStringByAddress
We don't use abbreviations in names.
2023-04-04 09:30:09 +02:00
Pietro Fezzardi 4c2602e956 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-04-04 09:30:09 +02:00
Kacper Kołodziej 1b8801c9dc Add RawBinaryView::isReadOnly method
isReadOnly returns true if segment which contains region defined with
 MetaAddress and size is not writable.
2023-04-04 09:30:08 +02:00
Giacomo Vercesi 2e96e09f63 Drop analyze-all
Drop all the uses of analyzeAll and swap its use with the invocation of
the appropriate analysesList
2023-03-22 17:50:02 +01:00
Massimo Fioravanti 312e2e8d53 Add analyses lists
Introduces the possibility of specifiying lists of analyses as way to
give them coherent names.
2023-03-22 17:31:46 +01: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 c2f0fc19e5 ABI: FunctionType.h -> FunctionType/Layout.h 2023-03-15 10:28:24 +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