Commit Graph

3168 Commits

Author SHA1 Message Date
Pietro Fezzardi 97883844d3 Fix initialization of FunctionTags 2023-01-17 11:11:46 +01:00
Kacper Kołodziej 568bd24900 Add UnaryMinus and BinaryNot 2023-01-09 15:01:16 +01:00
Andrea Gussoni 80ea234167 Fix ContinueNode emission 2023-01-05 16:33:21 +00:00
Alessandro Di Federico c6630a2414 eraseIfNoUse: check if WeakVH is dead 2023-01-03 20:51:45 +01:00
Alessandro Di Federico a4f4906ba7 Lift: re-enable InstCombine upon harvesting
InstCombine was disabled in favor of some more basic constant
propagation, but it turns that under certain circumstances this leads to
direct branches appearing as indirect branches until we run InstCombine
during finalization, which triggers an assertion, since we do not expect
any direct jump there.

If this, affects translation performance, we can think to run it less
often.
2023-01-03 13:41:40 +01:00
Alessandro Di Federico 8030f1c909 finalizeNewPCMarkers: do not copy attributes 2023-01-03 13:41:40 +01:00
Alessandro Di Federico dd5914ce61 ProgramCounterHandler: initialize field
The uninitialized field led to SIGSEGVs.
2023-01-02 14:22:56 +01:00
Alessandro Di Federico 991980806e LinkForTranslation: use -l:ld-linux-x86-64.so.2 2023-01-02 10:46:13 +01:00
Pietro Fezzardi 1a3d752814 MarkAssignments::Flags: drop unused method 2022-12-24 03:03:05 +01:00
Pietro Fezzardi adf0e30081 OperatorPrecedenceResolutionPass: fix QEMU helpers
We always emit a variable for calls to QEMU helpers. For this reason,
for what concerns operator precedence, calls to QEMU helpers should be
considered as references to variables. Hence, they should never be
parenthesized.
2022-12-24 03:01:48 +01:00
Pietro Fezzardi 73507a8d26 SegregateStackAccessesPass: fix pusing calls ALAP
Before this commit, calls were marked to push ALAP in the wrong order,
resulting in preventing to actually push them ALAP.

This commit fixes the ordering, reactivating the code motion.
2022-12-24 03:01:48 +01:00
Pietro Fezzardi e9d84264ff Reduce the number of emitted local variables in C
This commit does various things oriented at reducing the number of local
variables emitted in C:
- MarkAssignments now know that @Copy and @Assign involving
  @LocalVariable only have side effects that affect the local variable
  itself; this enables to reduce the number of times we're forced to
  emit a local variable due to interfering side effects
- Drop the @AssignmentMarker FunctionTag; AddAssignmentMarkerPass now
  doesn't emit @AssignmentMarker anymore; instead it emits groups of
  @LocalVariable, @Copy, and @Assign, which benefit from the previous
  point
- Drop 2 MarkAssignments::Reasons: HasManyUses and HasUsesOutsideOfBB;
  both these have now been aggregated into the AlwaysAssign reason for
  simplicity, representing all reasons non involving side effects
- Update BeautifyGHAST and how it reasons about side effects when
  beautifying; before this commit it used @AssignmentMarker, now it
  looks at @Assign
- Simplify ExitSSA; before this commit it was trying hard to be smart on
  where it emitted the store instructions representing the incoming
  values of the PHI that was being destroyed; this seemed smart when we
  originally did it but it generated C code that was not really better
  to read, so this useless complexity is finally gone
2022-12-24 02:47:10 +01:00
Pietro Fezzardi c201990e5b Print stack variable at beginning of function body 2022-12-24 02:44:38 +01:00
Djordje Todorovic 74c840a9f5 DwarfImporter: set prototype only if available 2022-12-13 11:27:23 +01:00
Djordje Todorovic 8976ab4126 DwarfImporter: handle DW_AT_noreturn 2022-12-13 11:27:16 +01:00
Djordje Todorovic 961f9e5461 Model: search debug info locally upon import
Also find prototypes in Models of dynamic libs for both PE and ELF.
2022-12-13 11:26:54 +01:00
Djordje Todorovic cad68a9876 Instroduce LDDTree 2022-12-13 11:26:25 +01:00
Massimo Fioravanti 742e1a0c56 TupleTree: switch from public fields to accessors 2022-12-12 18:36:57 +01:00
Massimo Fioravanti 87aef3fbad revng-c now uses Model accessors 2022-12-12 11:35:52 +01:00
Massimo Fioravanti a54d1c9dcb fix includes 2022-12-12 11:19:14 +01:00
Massimo Fioravanti 0d3133cfc9 Fix missing includes
This ensures headers make sense on their own, without implicit
assumption about includers to also include other headers before them.
2022-12-09 18:09:39 +01:00
Alessandro Di Federico 0245bf81d7 stringAsPath: 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 93872783f7 yield::ControlFlowGraph: use ROOT_TYPE 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 63e3330bab efa::FunctionMetadata: use ROOT_TYPE 2022-12-09 09:12:28 +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 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
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
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 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 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 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 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