Commit Graph

6113 Commits

Author SHA1 Message Date
Alessandro Di Federico 66b12ad540 Yield: move CrossRelation into its own directory
Also, use ROOT_TYPE.
2022-12-09 10:11:27 +01:00
Alessandro Di Federico 63e3330bab efa::FunctionMetadata: use ROOT_TYPE 2022-12-09 09:12:28 +01:00
Alessandro Di Federico 22c1ec78eb TupleTree: handle type-erased visitors
This commit reduces build times by introducing a type-erasure layer when
performing a visit on TupleTrees. Basically instead of propagating the
type of the visitor along all of the template castle, we wrap the
visitor into a virtual class with one method for each possible type in
the TupleTree.
This enables a single instatiation of visit algorithm.
2022-12-09 09:10:39 +01:00
Alessandro Di Federico 693b361e4a TupleTree: externalize several methods 2022-12-09 09:08:40 +01:00
Alessandro Di Federico 3a7b78584f Externalize cl::opt generations in Debug.h
These have a significant impact on build times.
2022-12-09 09:07:59 +01:00
Alessandro Di Federico de976fab13 Externalize ModelWrapper::get*Model 2022-12-09 09:07:16 +01:00
Alessandro Di Federico bffbd58434 tuple_tree_generator: generate one .cpp only 2022-12-09 09:07:06 +01:00
Alessandro Di Federico 58c6e095b6 TTG CMake: one target, many schemas
This commit ensures that `target_tuple_tree_generator` can handle being
invoke multiple times on the same target.
This avoids the need to create a dedicated library as a workaround.
2022-12-09 09:05:14 +01:00
Alessandro Di Federico c3fc2d1f88 TupleTreeDiff deserialization: fix initialization
We used to assign an uninitialized field to `false`. However, what we
really wanted to is to construct the optional by invoking the default
constructor of the `value_type` of the optional.
2022-12-09 09:02:35 +01:00
Alessandro Di Federico 821f3b169a abi/test.sh: fix shellcheck warning 2022-12-09 09:02:29 +01:00
Alessandro Di Federico e9db913291 Disassembler: fix iterator invalidation issue
The index of an element of a `SortedVector<yield::Tag>` was saved, but
`SortedVector` behaves like a set.
The issue has been fixed by creating a temporary `Tag` instead of trying
to keep a reference to an existing one.
2022-12-09 09:00:20 +01:00
Alessandro Di Federico 98025f4dbe yield::Tag: let TTG emit the key 2022-12-09 08:59:46 +01:00
Alessandro Di Federico c75a3450c1 TupleTree::deserialize: drop useless yaml::Input
This was a leftover from yaml::Input usages centralization.
2022-12-09 08:58:30 +01:00
Pietro Fezzardi a72f24ef5a DLAUpdateModelTypes.cpp: fix update of stack frame 2022-12-05 17:03:21 +01:00
Pietro Fezzardi de0b22a842 DecompileFunction.cpp: avoid useless newline 2022-12-05 15:59:42 +01:00
Pietro Fezzardi b0e974f7a4 MakeModelGEPPass: fix adds with constants 2022-12-02 17:23:25 +01:00
Pietro Fezzardi e1d8d4ff9e DecompileFunction.cpp: fix hexLiteral
formatv("{0:x}", Int) was printing the address of the integer, not the
integer itself.
2022-12-02 14:40:09 +01:00
Pietro Fezzardi c67493d2c3 PrettyIntFormattingPass.cpp refactor 2022-12-02 12:59:47 +01:00
Kacper Kołodziej 83ab07d7fb Enable printing integers as bool, hex or char
This commit adds a new pass, PrettyIntFormatting, that injects calls to
decorator functions print_hex, print_char, and print_bool around
llvm::ConstantInt in various situations.

It also updates the rest of passes of the decompilation pipelin to
understand these new decorator functions and to properly emit decorated
integer literals in the decompiled C code.
2022-12-02 10:08:00 +01:00
Pietro Fezzardi ae47112ec4 Merge branch feature/cabi-fixes 2022-12-01 12:21:27 +01:00
Alessandro Di Federico 049b8657c3 Introduce RemoveStackAlignmentPass 2022-12-01 12:20:09 +01:00
Alessandro Di Federico 32e8333f58 PromoteStackPointer: handle CABIFunctionType 2022-12-01 12:20:09 +01:00
Pietro Fezzardi 1026b732f8 Merge branch feature/combing-improve-loop-entries 2022-12-01 12:15:53 +01:00
Pietro Fezzardi a18cc9078f RestructureCFG.cpp: drop legacy removeFromRPOT
This can be replaced with concise idiomatic llvm::erase_value
2022-12-01 12:15:12 +01:00
Pietro Fezzardi 02bafadce7 RestructureCFG: new election of loop entry points
The new criterion for electing the entry point of a loop is based on the
number of edges that jump to the candidate entry from outside the
region.
2022-12-01 12:15:12 +01:00
Pietro Fezzardi e95f77aeb6 RegionCFG::isDAG: use llvm::scc_iterator::hasCycle 2022-12-01 12:15:12 +01:00
Pietro Fezzardi cadb71f2b2 RegionCFGTreeImpl.h: use std::erase_if 2022-12-01 12:15:12 +01:00
Pietro Fezzardi 3a329b0d95 MetaRegion: drop unused method getProbableEntry 2022-12-01 12:15:12 +01:00
Pietro Fezzardi c73b447c60 Use MFP in RegionCFG::inflate for reachable exits 2022-12-01 12:14:37 +01:00
Pietro Fezzardi 794663c741 Merge branch feature/cabi-prototypes 2022-11-30 18:16:39 +01:00
Alessandro Di Federico 00bc0b594b Segregate tests: run full decompilation
This is just for regression testing purposes, we need to have proper
testing on the emitted C.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi ee0dc97464 Uniform printing return types of functions 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 7b66b9d7f6 TypeNames: fix redundant whitespaces in types 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 080a7ae442 Test returning aggregates 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 2e2489e79d ModelTypeNames: handle returning aggregates 2022-11-30 18:16:13 +01:00
Alessandro Di Federico d5f1ee1155 MakeModelGEP: handle returning aggregates 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 4937fd29a0 ModelHelpers: handle returning aggregates 2022-11-30 18:16:13 +01:00
Alessandro Di Federico c5ab81cd08 Segregate: handle aggregate return values 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 7f6735f212 ModelHelpers.h: add stripPointer helper
This assumes that the input QualifiedType has at least one Qualifier,
and that the first Qualifier is a pointer-qualifier.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 39c673a4c4 Rework tests 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 389a184fc2 Handle CABIFunctionTypes returning struct types 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 3d6020139f Add type argument to 'revng_call_stack_arguments'
The additional argument is a pointer to a constant string that represent
the serialized model::QualifiedType of the argument.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 05c96a1a3a Adopt abi::FunctionType::ArgumentKind 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 28cb749573 Fix usage of revng_call_stack_arguments in calls
Before this commit, we did not take into consideration that
revng_call_stack_arguments has reference semantics, and we were using
its AddressOf in call sites that were taking the stack arguments.

This commit fixes the problem, bypassing the call to AddressOf when
passing the arguments to calls.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi daec840e37 Fix getStrongModelInfo for stack arguments
Before this commit, the code was assuming that we only passed stack
arguments to fuctions with RawFunction type. This is not true anymore.

This commit adds support to getStrongModelInfo for when we are passing
stack arguments to CABIFunctionType.
2022-11-30 18:16:13 +01:00
Pietro Fezzardi d3f2584158 DLA: fully support update of CABIFunctionTypes 2022-11-30 18:16:13 +01:00
Alessandro Di Federico f94ec452f4 SegregateStackAccesses: trunc stack arguments 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 23dd27b6b6 Ignore stack arguments, if stack size unknown
This commit handles the situation in which we have a call site with
stack arguments, but it was not possible to determine the stack height
at the call site.

The solution is to simply ignore stack arguments and emit in the IR a
warning.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 800b8e6f16 DecompileFunction: handle string literals
We now emit global variables that are NULL-terminated strings inline.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 537c1e7524 IRHelpers: introduce emitMessage 2022-11-30 18:16:13 +01:00