Commit Graph

6113 Commits

Author SHA1 Message Date
Ivan Krysak 150fab6bbc Fix a minor pipeline::Target construction issue 2022-06-14 12:40:11 +03:00
Ivan Krysak 257bcb9b3c Make MetaAddress constexpr constructible 2022-06-14 12:40:11 +03:00
Ivan Krysak dffe311ad8 Add efa::FunctionEdgeType::needsFallthrough 2022-06-14 12:40:11 +03:00
Pietro Fezzardi 71b99464fe MakeModelGEPPass: consider type size in scoring 2022-06-14 10:56:56 +02:00
Pietro Fezzardi db1085a167 Merge branch feature/pipeline-multiple-branches 2022-06-14 10:29:41 +02:00
Massimo Fioravanti 132cfe4d80 Fix pipeline yml file to support multiple branches 2022-06-14 10:29:17 +02:00
Giacomo Vercesi 1cc8c2c20c Fix pyYAML type error
Remove code in revng.cli.model_dump and override_by_name that was used
when the model had tags. The code subclassed the default pyYAML loader
to ignore unknown tags to allow reading the model data easily. Since the
model no longer has tags this code is dead and can be removed.
2022-06-13 18:35:37 +02:00
Massimo Fioravanti 22bce466b1 revng-pipeline: support handles multiple branches
This commit introduces the possibility to have multiple pipeline
branches in a single YAML pipeline file.
2022-06-13 18:34:03 +02:00
Massimo Fioravanti f8ad4e634d Replace pipeline -load using LLVM -load mechanism
`revng -load` mechanism did not allow to specify arguments for loaded
libraries, the new LLVM mechanism allow to do so.
2022-06-13 18:30:08 +02:00
Pietro Fezzardi 43fb18219b MakeModelGEPPass: fix comparison of QualifiedTypes
This comparison was used to sort the best results among candidates for
creating ModelGEPs.

However the comparison itself was broken, i.e. you could have 2
different QualifiedTypes T1 and T2 such that T1 < T2 AND T2 < T1.
This caused broken sorting and non-deterministic selection of the best
ModelGEP substitution.

This commit fixes the comparison and as a result the selection of the
best candidate for the emission of ModelGEPs is not completely
deterministic.
2022-06-13 16:52:17 +02:00
Alvise de Faveri 66e077fdcb Support: Fix dropPointer() 2022-06-13 15:21:49 +02:00
Alvise de Faveri b13286cf04 Backend: Fix buildCastExpr() conditions 2022-06-13 15:20:57 +02:00
Alvise de Faveri 16fba5be15 DLA: Never create a new type for the stack 2022-06-13 15:20:07 +02:00
Alvise de Faveri 5a41669d2e ModelGEP: Never initialize types from LLVM IR 2022-06-13 15:19:15 +02:00
Alvise de Faveri c65b172af6 Backend: Emit '\n' after while loops 2022-06-13 15:18:22 +02:00
Alvise de Faveri fe09f519f7 Backend: Fix callee parentheses in indirect calls 2022-06-13 15:16:51 +02:00
Pietro Fezzardi 6f41e625e7 DeduplicateUnionFields is now DeduplicateFields
Before this commit, the dla::Step depended on InterferingInfo, but this
was superfluous.

This commit drops the dependency and enables the Step to run before
ComputeNonInterferingComponents.

This also avoids the need to run ComputeNonInterferingComponents twice
(one before and one after DeduplicateUnionFields), so it can only run
once.
2022-06-08 14:16:51 +02:00
Pietro Fezzardi 3e53eced5d CollapseSingleChild: ignore InterferingInfo
Before this commit, CollapseSingleChild Step was thinkering around
with InterferingInfo.

Now CollapseSingleChild does not care about InterferingInfo anymore, so
the code handling it can just be dropped.
2022-06-08 14:13:01 +02:00
Pietro Fezzardi 9898c980d7 DLA: make TypeLinkTag serializable to Loggers 2022-06-08 14:11:55 +02:00
Pietro Fezzardi 5a37fe8a84 DLA: add MergePointerNodes Step
This Step merges nodes with outgoing pointer-edges pointing to the same
pointee node.
2022-06-08 10:22:35 +02:00
Pietro Fezzardi ba50eb4a55 DLA: revive and rework CollapseSingleChild Step
The step now collapse parents with their single child if they are
indistinguishable, i.e. if the parent has only that single child, at
offset zero, and their size is the same.
2022-06-08 10:21:44 +02:00
Pietro Fezzardi be999ebda8 DLAComputeNonInterferingComponents: drop assert 2022-06-08 10:21:01 +02:00
Pietro Fezzardi 5c9ae203e6 DLA: fix deps for ComputeUpperMemberAccesses 2022-06-08 10:20:13 +02:00
Pietro Fezzardi 546175cc75 Fix typo in comment 2022-06-08 10:18:40 +02:00
Alvise de Faveri 91f9a17e4a Backend: Add cast to return value 2022-06-01 11:37:25 +02:00
Alvise de Faveri dd6ef1d4a8 Backend: Improve parenthesis 2022-06-01 11:35:50 +02:00
Alvise de Faveri 06d72f1cd9 Backend: Improve logging 2022-06-01 11:34:18 +02:00
Alvise de Faveri 51df8ad64d Backend: Fix select emission 2022-06-01 11:29:09 +02:00
Alvise de Faveri 52dd37d0ed HelpersToHeader: Whitelist helpers
Explicitly list the functions whose prototype should be serialized
in the `revng_helpers` header. This is more robust with respect to
future opcodes added in the IR.
2022-06-01 11:27:34 +02:00
Alvise de Faveri e3e5210084 DLA: Ignore offsets greater than 64K
When creating the DLA graph, we want to avoid inserting `instanceOf`
edges with huge offsets, so we set a limit to 64K.

This is a workaround to handle cases in which we make wrong decisions
about the base address of a SCEV expression. One of the situations in
which this occurs are expressions such as `&val + BIG_CONST`, for which
we always identify `%val` as the address and `BIG_CONST` as the offset.

When fixing this case, we should still verify that this never happens.
2022-06-01 11:25:59 +02:00
Alvise de Faveri 99b06894c4 GHAST: Fix NotAAnd(Not)B short-circuiting 2022-06-01 11:24:20 +02:00
Alvise de Faveri 64c096df0b GHAST: Mark printing helpers as debug_functions 2022-06-01 11:22:43 +02:00
Alvise de Faveri 7f37a22b5d Support: Improve peelConstAndTypedefs constness 2022-06-01 11:21:02 +02:00
Alvise de Faveri 00c022119e Support: Add isCallToTagged() helper 2022-06-01 11:19:24 +02:00
Alvise de Faveri 190e91f4f4 Support: Add getPointerSizedInteger() 2022-06-01 11:17:42 +02:00
Alvise de Faveri e9fcdc3f2a Support: Convert LLVM types as generic types 2022-06-01 11:09:15 +02:00
Alvise de Faveri c7264badae Support: Add serializeToLLVMString(QualifiedT) 2022-06-01 11:08:29 +02:00
Alvise de Faveri 189fbe4651 Support: Fix the key for OpaqueExtractValue pool
Calls to `OpaqueExtractValue()` are meant to replace `extractvalue`s
found in the LLVM IR. Since the type of an `OpaqueExtractValue` is
identified by both the return type (extracted value) and the first
argument's type (aggregate operand of the `extractvalue` instruction),
we need to consider both when building the associated FunctionPool.

Previously, we were identifying each `OpaqueExtractValue` variant using
only the returned value, which was wrong. In fact, if we have two
`extractvalue` instructions that extract a value of the same type
(e.g. i32) from two different aggregate types (e.g. structA and
structB), we have to define two different `OpaqueExtractValue`: one
that returns an i32 and has a parameter of type structA, and one that
returns an i32 and has a parameter of structB. If we use only the
return type, we are not able to distinguish the two.
2022-06-01 11:05:31 +02:00
Alvise de Faveri 9d18c58698 CMake: Always regenerate headers in backend tests
Add an explicit dependency between the last decompilation stage and the
headers generation passes, so that we always regenerate decompilation
headers when executing the decompilation step of each test.
2022-06-01 11:02:50 +02:00
Pietro Fezzardi 0ddbc72bbf Merge branch feature/promote-init-csv-to-undef 2022-05-31 12:51:59 +02:00
Pietro Fezzardi f62cdc1181 RemoveLiftingArtifacts: promote init_* to undef 2022-05-31 12:40:52 +02:00
Pietro Fezzardi 18b9e481c8 Backend: fix emission of integer constants
Before this commit we were using a suboptimal API that often resulted in
expressions with many zeros for the 0 constant, e.g. 0000000 instead of
just 0.

This commit fixes the problem.
2022-05-31 12:40:52 +02:00
Pietro Fezzardi 229648a6cb Backend: fix casts in assignments expressions
Before this commit source and destination types were swapped.
2022-05-31 12:40:52 +02:00
Pietro Fezzardi d02f51c0f0 SegregateStackAccessesPass: handle dead code
Before this commit, SegregateStackAccessesPass always expected to find
calls stack_size_at_call_site markers injected by
InjectStackSizeProbesAtCallSitesPass.

This is not always true, because aggressive LLVM optimizations can
remove dead code.

As an example, if the user or some analysis earlier in the pipeline
wrongly marks registers as non-arguments, the optimization pipeline will
throw away and eliminate everything that descends from the initial
values of those registers.

This commit enables SegregateStackAccessesPass to cope with calls to
stack_size_at_call_site that were eliminated, and keep going just
considering the calls that are still there.
2022-05-31 12:40:52 +02:00
Pietro Fezzardi 4ed636cbba Support emission in C of null pointers 2022-05-31 12:40:52 +02:00
Pietro Fezzardi 35e0e688d2 Support emission in C of integer or pointers undef 2022-05-31 12:40:52 +02:00
Pietro Fezzardi 67c6c81e53 MakeModelGEP: ignore undef and null addresses 2022-05-31 12:40:52 +02:00
Alessandro Di Federico d37c3d3dd8 Fix revng --prefix
When running subcommands from a `revng` script the build directory and
the root directory were being swapped.
2022-05-31 11:30:10 +02:00
Pietro Fezzardi 2651b8765b DLA: drop CollapseCompatibleArrays
This pass was never implemented and we don't have plans to do it soon.
This commit just drops it to reduce the noise.
Whenever we decide to implement something similar we'll do it from
scratch.
2022-05-27 17:06:49 +02:00
Pietro Fezzardi 31419a5fd1 Remove old unused dla::Layout class
This class was introduced before having model::Type, to represent
roughly the same information.

Now it's dead code and this commit removes it.
2022-05-26 16:46:47 +02:00