Commit Graph

2366 Commits

Author SHA1 Message Date
Alessandro Di Federico a96270a8aa TupleTree::visit: externalize 2022-12-09 10:11:27 +01:00
Alessandro Di Federico 974dd0c680 yield::Function: do not use efa::BasicBlock
This change introduces some duplication but ensures an important
property of `tuple_tree_generate`d: data structures: all the leaves are
scalars. Previously, yield::Function was using efa::BasicBlock, making
things more difficult under certain conditions.
Specifically, we can rely on the fact that, when generating a visit to
the TupleTree, we know everything about all non-scalars.
2022-12-09 10:11:27 +01:00
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 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 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 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
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
Alessandro Di Federico 049b8657c3 Introduce RemoveStackAlignmentPass 2022-12-01 12:20:09 +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 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
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
Pietro Fezzardi 389a184fc2 Handle CABIFunctionTypes returning struct types 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 537c1e7524 IRHelpers: introduce emitMessage 2022-11-30 18:16:13 +01:00
Ivan Krysak 033ccbe51a Adopt FunctionType::Layout to improve CABI support 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 185df966b7 LLVMContainer: s/REVNG/revng./g 2022-11-30 15:06:54 +01:00
Alessandro Di Federico 06d4c3a5ed LLVMContainer: infect DataLayouts upon linking 2022-11-30 15:06:54 +01:00
Massimo Fioravanti 452d10950e Pipeline: only remove targets in the container
This commit ensures that only content that is actually inside a
container is elegible to be removed.
2022-11-30 15:06:54 +01:00
Pietro Fezzardi e62aa0166e FunctionType::Layout: introduce argument kind
This commit introduces a `Kind` for arguments described in
`FunctionType::Layout`. We nowe basically have three types of arguments:

* Scalar: a regular scarlar argument;
* ReferenceToAggregate: a reference to an aggregete argument on the
  stack;
* ShadowPointerToAggregateReturnValue: a pointer to the storage for the
  (aggregate) return value allocated by the caller;
2022-11-30 15:06:54 +01:00
Ivan Krysak 855999f5f0 Layout: add support for multiple return values 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
Ivan Krysak afdd3302d8 STLExtras: add constepxr version of find 2022-11-30 15:06:54 +01:00
Ivan Krysak 1f4b5dfd36 Model: associate a primitive kind to each register 2022-11-30 15:06:54 +01:00
Ivan Krysak 207668070a QualifiedType: add argument-less isPrimitive() 2022-11-30 15:06:54 +01:00
Ivan Krysak c3c3ed4381 Move pointer creation away from model::Binary 2022-11-30 15:06:54 +01:00
Alessandro Di Federico b83edd61c0 DwarfImport: fix handling of local functions 2022-11-30 15:06:54 +01:00
Massimo Fioravanti 044071435e Fix handling of binaries with no functions
Fix various edge cases when a binary with no functions was analyzed.
2022-11-22 16:19:28 +01:00
Massimo Fioravanti a057ce54a7 Avoids missing outputs when empty
FileContainer should not be used when we wish to produce a empty output
file rather than no file at all.
2022-11-22 15:21:03 +01:00
Massimo Fioravanti 0bfb73fe95 FunctionMetadata: introduce cache
FunctionMetadata was being deserialized every time they were
inspected. This commit introduces a cache structure to prevent this
excessive deserializations.
2022-11-22 14:15:00 +01:00
Massimo Fioravanti 335d402245 Change signatures to forward metadata cache. 2022-11-22 12:27:02 +01:00
Pietro Fezzardi 764c7efbb8 Make isCallTo accept any llvm::Value * 2022-11-22 10:12:34 +01:00
Pietro Fezzardi fd0914b460 QualifiedType: add isConst method 2022-11-22 10:12:31 +01:00
Pietro Fezzardi 8aaa3ca92e Refactor PTML generation for functions 2022-11-16 16:02:09 +01:00
Pietro Fezzardi e72a578743 Refactor PTML generation for local variables 2022-11-16 11:24:37 +01:00
Pietro Fezzardi 79a319cdeb PTML.h: sort ptml::c::tokens alphabetically 2022-11-16 07:48:43 +01:00
Pietro Fezzardi 0812989cb0 Drop unused ptml::c::tokens::Comparison 2022-11-16 07:47:18 +01:00
Pietro Fezzardi a23d4f8dcf Ranks.h: simplify ranks, delete unnecessary ranks 2022-11-15 15:54:20 +01:00
Pietro Fezzardi ff631c5364 PTMLC.h: switch to string-based return values 2022-11-15 15:54:20 +01:00
Pietro Fezzardi c93392fa3b Refactor PTML generation for helpers 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 38ce08edba PTMLC: add Const keyword 2022-11-15 15:54:20 +01:00
Pietro Fezzardi e1ded3a479 HelpersToHeader: refactor PTML Tags 2022-11-15 15:54:20 +01:00
Pietro Fezzardi 2ec8b7e32c ModelToHeader: refactor creation of PTML Tags 2022-11-15 15:54:20 +01:00