Commit Graph

356 Commits

Author SHA1 Message Date
Giacomo Vercesi a2b7d0e0bf PipelineC: add tracing
Add support for tracing onto the PipelineC. This is done by:
1. Creating wrapper functions for each PipelineC function with the
   script in `scripts/PipelineC_add_tracing.py`. These will call a
   special function called `wrap` which will ultimately call a method
   with a `_` prepended to the name
2. Conversion of all PipelineC methods in `PipelineC.cpp` to `static`
   and their rename with a `_` in front, in order for them to work with
   the wrapper function in (1)
3. Generation of 2 additional include files, one for types and one for
   functions, to be used by users of tracing files in order to have
   introspection.

These steps allow the creation of a trace file with the use of the
`REVNG_C_API_TRACE_PATH` environment variable. The traces can then be
used in conjunction with the `revng trace run` and `revng trace
inspect` commands.
2023-04-20 14:43:13 +02:00
Giacomo Vercesi 8d89c6a318 PipelineC: rp_initialize: only use argc and argv
Switch from specifying `libraries` and `pipelines` in `rp_initialize`
and `rp_manager_create` to the use of command-line options that are to
be passed via `argc` and `argv` in `rp_initialize`.
2023-04-20 14:43:12 +02:00
Giacomo Vercesi 9a972009d1 PipelineC: size and const-correctness
Fix the return type (often mismatched from uint64_t to int) and the
const-correctness of many functions in PipelineC
2023-04-20 14:43:12 +02:00
Alessandro Di Federico 8fd34ff0f7 pruneDICompileUnits: delegate to DIFinder 2023-04-14 08:36:05 +02:00
Alessandro Di Federico 5be2c94a1b Fix literal signedness in comparisons 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 dbcdad0a4d Switch from llvm::Optional to std::optional 2023-04-08 08:42:24 +02:00
Alessandro Di Federico 5ed9432a68 Fix ambiguous template function
Bumping LLVM version turned these into compiler errors.
2023-04-08 08:42:23 +02:00
Alessandro Di Federico 31b46de38c Remove dead code and fix spurious warnings
Remove some dead code or introduce suppressions for spurious.
These are results of more accurate warnings in clang 16.
2023-04-08 08:42:23 +02:00
Alessandro Di Federico 74ae629853 Drop experimental from coroutines 2023-04-08 08:42:23 +02:00
Alessandro Di Federico 52521f8cac Adopt more standard library's features 2023-04-08 08:42:23 +02:00
Massimo Fioravanti fc3f106640 Pipeline: fix accidental container materialization
Pipeline lazy containers were incorrectly materialized when it was not
necessary.
2023-04-07 14:37:14 +02:00
Ivan Krysak 9475eefe76 ABI-testing: add unit tests for the alignment 2023-03-15 10:19:03 +01:00
Ivan Krysak 1f439cbb8c ABI-testing: extend to support unusual alignment
Because it's often hard to predict the specific location of an argument when
non-natural alignment is concerned, this adds an extra check allowing
the cases to pass if they would be well-formed if only some pesky
"extra" bytes were to disappear.
2023-03-15 10:19:03 +01:00
Ivan Krysak 750b6361a8 ABI-testing: add SPTARV support 2023-03-15 10:19:03 +01:00
Ivan Krysak d65ed50e0b ABI-testing: allow explicit abi overrides
Since dwarf sometimes misdetects abi pretty badly, to maintain
the usefulness of the test, it's beneficial to sometimes discard
the "detected" ABI by overriding it by the known value.

This also add a check ensuring that all the functions presents in
the artifact are also present in the binary.
2023-03-15 10:19:03 +01:00
Ivan Krysak a7be2cd11b ABI-testing: improve robustness against padding
Some cases of irregular padding were causing issues when verifying
arguments which varanted a bit of the rework of the main verification
loop.
2023-03-15 10:19:03 +01:00
Ivan Krysak 15f8999fce ABI-testing: simplify compatibility checker
The complicated error handling logic turned out to be more of
a nuisance than a useful debugging tool. This commit removes it
in favour of `revng_abort`'ing or `revng_check`'ing to make sure
the actual state is consistent with the expectations.

It also adds namespace to `std::size_t` mentions.
2023-03-15 10:19:03 +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 84229d92b1 Model & ABI: make size and alignment stricter 2023-03-15 10:19:02 +01:00
Ivan Krysak 58b33ea7af ABI-testing: make rtf-equivalence id-independent 2023-03-15 10:19:02 +01:00
Ivan Krysak 7daa187107 ABI-testing: support returning values as a pointer 2023-03-15 10:19:02 +01:00
Ivan Krysak ad0fc079b8 ABI-testing: rename verify-abi
The new name is `check-compatibility-with-abi`
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 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
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 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 230036d5b1 Introduce TrackingContainer
TrackingContainer is a wrapper around KeyedObjectContainers (notably,
SortedVector) intended to figure out which elements of the underlying
container have been accessed.
2023-02-16 10:58:02 +01:00
Massimo Fioravanti 4dc2e92782 Introduce DocumentError
`DocumentError`s are the inteded way of propagating errors from the
pipeline to the frontend when a location is required to inform the user
of the error whereabouts.
2023-02-09 13:42:50 +01:00
Massimo Fioravanti dad043027d Rework and EFA yield cross relations
Yield and EFA shared the same namespace, this commits splits them and
introduces tuple tree containers as well.
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
Alessandro Di Federico 207426cdf2 tests/unit/Model: drop unnecessary tests 2022-12-09 10:11:27 +01:00
Alessandro Di Federico 10852adae6 TestClass: use ROOT_TYPE 2022-12-09 10:11:27 +01:00
Alessandro Di Federico 693b361e4a TupleTree: externalize several methods 2022-12-09 09:08:40 +01:00
Pietro Fezzardi df30792435 PrimitiveType: support for 80 and 96 bits types
This commit completes the support of various rare PrimitiveTypes, that
has been added opportunistically over time and has remained inconsistent
across the codebase:

- float80_t
- float96_t
- generic80_t
- generic96_t

The first two are necessary because on some platforms long double is
either 10 or 12 bytes wide.

The second two are necessary because the Generic PrimitiveType should
allow all non-zero byte sizes allowed by any other PrimitiveType.
2022-11-30 15:06:54 +01:00
Ivan Krysak 535c9dd346 ABI: remove MinimumStackArgumentSize value
The architecture-specific pointer (generic register) size is used
instead.

For all the ABIs we support the value of this parameter was already
set to its pointer size. We might need to reintroduce the parameter
in the future if we want to support a super-exotic ABI with different
stack alignment requirements, but that seems highly unlikely.

This also introduces the argument extension helper for one stop all
treating small arguments when they are put into a register or pushed
into the stack.
2022-11-30 15:06:54 +01:00
Giacomo Vercesi 7526d72492 Kinds: exposed locations produced
Expose the locations that can be found in each kind
2022-11-11 13:43:55 +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 d55aa9b9e6 Pipeline: remove * from targets
Now * is just a pipeline frontend shorthand.
2022-10-20 14:20:12 +02:00
Giacomo Vercesi 677fe190be Ranks: split TypeField
Split the TypeField Rank in 3 more specific ranks: StructField,
UnionField and EnumMember.
2022-10-11 17:10:46 +02:00
Giacomo Vercesi d7265ff160 PipelineC: allow signal masking
Some users of PipelineC might be interested in preserving
pre-existing signals, this commits adds this functionality.
2022-10-04 14:13:56 +02:00
Massimo Fioravanti 049ba69d43 Pipeline: containers can now enumerate their kinds 2022-09-29 15:55:30 +02:00
Massimo Fioravanti dc23473d85 Introduce Loader::getRegistered{Pipes,Analyses} 2022-09-29 15:55:16 +02:00
Massimo Fioravanti 445bc2aa8c Pipeline: introduce registry for container types 2022-09-29 15:52:26 +02:00
Massimo Fioravanti 9363bbd70a Pipeline: every container type has now a C++ type 2022-09-29 15:51:17 +02:00
Giacomo Vercesi bf4122ed0a Introduce v2 of revng-check-conventions 2022-09-29 15:21:59 +02:00
Alessandro Di Federico 85d574b305 test-abi: various fixes 2022-09-21 18:39:28 +02:00