Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico 6b4f44af2d Minor changes 2024-03-01 14:53:06 +01:00
Alessandro Di Federico 2347304b70 Progress.cpp: handle StepsCount == 0 2024-03-01 14:23:30 +01:00
Alessandro Di Federico 340b02c71e DwarfImporter: improve progress reporting 2024-03-01 14:23:08 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Andrea Gussoni e1a49e417f ALAPVariableDeclaration: introduce ALAP Var Decl
Perform the ALAP Variable Declaration process.
The process is structured in the following stages:
- We start by collecting all the `Variable`s that need to be assigned in
  a `ASTNode`.
- We build a `GenericGraph` where each `ASTNode` is connected with its
  child nodes, and also its immediate successor.
- We perform a walk in post order over this graph, and for each
  `ASTNode` we decide if the current node could be the ALAP location
  where we can declare the `Variable`, i.e., where we dominate all its
  uses.
2024-02-20 16:35:36 +01:00
Andrea Gussoni 3966d57cfd DecompileFunction.cpp: move helpers to header file
Move some helper functions to the `DecompilationHelpers.h` file in order
to use them from other `.cpp` files.
2024-02-20 16:35:36 +01:00
Ivan Krysak 3e48504675 PrepareIR: base anonymous struct names on ID alone 2024-02-20 14:35:56 +01:00
Ivan Krysak 6adee367ee RemoveExtraValues: simplify the pass
Simplification includes dropping dependencies onto
`FunctionMetadataCachePass` and `LoadModelWrapperPass`, as well
as removing "StructName" logic outright.
2024-02-20 14:35:56 +01:00
Andrea Gussoni d4d5e1a966 GenerateAst: rewrite SwitchNode tiling
Perform a complete rewrite of the `SwitchNode` tiling routine.
The tiling now works in the following way:
- When encountering a node which will produce a `SwitchNode` (either a
  standard `switch` or a dispatcher `switch`), we look for the following
  situations:
  1) We have a node, a successor (case) of the `switch`, which in turn
     is the successor of all the other successors (cases) of the
     `switch`.
  2) We have a node, not a successor (case) of the `switch`, which is
     the successor of all the successors (cases) of the `switch`.
- If we find such candidate node, this node will be the fallthrough of
  the `switch`. In addition, depending on whether the `switch` dominates
  the candidate fallthrough, we can incorporate it as the immediate
  successor of the `SwitchNode` we are building.
- There is currently an exception to the above, due to how we currently
  handle weaved `switch`es. In such cases, we mandate that the weaved
  `switch` is nested inside the main corresponding `switch`. For this
  reason, we have a special casing handling the "all inlined but one"
  situation in the new code, while this part could in theory be merged
  in the common criterion below, at the cost of dropping the invariant
  of the nesting of weaved switch`es.
2024-02-16 15:42:27 +01:00
Andrea Gussoni 2542833bd7 InlineDispatcherSwitch: simplify empty cases
Simplify `switch` cases that are simplified away during the dispatcher
`switch` inlining beautify.
Usually, we can simplify ast nodes by replacing them with `nullptr`s,
but due to how the `switch` cases work, we need to handle them in a
custom way.
2024-02-15 14:28:28 +01:00
Andrea Gussoni 4f642f0e71 InlineDispatcherSwitch: SwitchBreak inlining
Support the situation where we want to inline a `SwitchBreak` node,
which is represented with passing `nullptr` as `InlinedBody`.
2024-02-15 14:28:28 +01:00
Ivan Krysak 069d3d3972 ToCABI: improve logger messages 2024-02-09 15:09:37 +00:00
Ivan Krysak e708a3655b ABI: drop incomplete clrcall support 2024-02-09 15:09:37 +00:00
Ivan Krysak c8cd0ab503 ValueDistributor: improve success log message 2024-02-09 15:09:37 +00:00
Ivan Krysak 27491410d6 ABI: introduce a way to disable vector registers 2024-02-09 15:09:37 +00:00
Ivan Krysak bc6673d90d ABI: make alignment-computation fails stricter 2024-02-09 15:09:37 +00:00
Ivan Krysak a018d443e1 ABI: update "safe" conversion list 2024-02-09 15:09:37 +00:00
Ivan Krysak 68301138c0 ABI: redesign register sorting from the ground up 2024-02-09 15:09:37 +00:00
Ivan Krysak 5bf4b3fa1e ABI: improve robustness to duplicate registers 2024-02-09 15:09:37 +00:00
Ivan Krysak fffbd27b99 Pipeline: be more explicit when step names collide 2024-02-09 15:09:37 +00:00
Ivan Krysak 9d815d79ec ToRaw: take advantage of the updated distributor
This lets us drop the repeated alignment calculations at
the "leaves" of the conversion. Since new distributor already
provides the necessary information, we can just grab it from
there.
2024-02-09 15:09:37 +00:00
Ivan Krysak 40e443f354 ArgumentDistributor: add a SPTAR helper 2024-02-09 15:09:37 +00:00
Ivan Krysak 526cb7385a ValueDistributor: support stack argument offset 2024-02-09 15:09:37 +00:00
Ivan Krysak 5c99229c6f ToRaw: fix issues with how types were selected
Pointer-to-copy support was severely flawed.
2024-02-09 15:09:37 +00:00
Ivan Krysak 65cf1f08fd Distributor: add explicit pointer-to-copy-support 2024-02-09 15:09:37 +00:00
Ivan Krysak a468698d23 ValueDistributor: be extra explicit around padding
Before this, padding was just handled as a part of the size, but that
made it unnecessarily hard to work with. Now, everything padding-related
is extremely explicit.
2024-02-09 15:09:37 +00:00
Ivan Krysak 2e78369ec9 Model: disable float register size mismatch check 2024-02-09 15:09:37 +00:00
Ivan Krysak 5994e4bf05 ToCAFT: always preserve stack types with metadata 2024-02-09 15:09:37 +00:00
Ivan Krysak af6f9367b2 ImportPE: remove i386-specific values 2024-02-09 15:09:37 +00:00
Djordje Todorovic 79460c6933 PDBImport: Handle forward referenced types
A class or a struct type A can be a forward declaration and refer
to another type B in PDB, so we need to follow the references.
We pre-create type for B, when we face type A, and then, when we
visit type B, we populate the fields for the model::type we
pre-created.

In addition, this patch fixes some minor/side bugs:
  - Handle SHORT/Int16Short simple type
  - Do not delete model::Function if Prototype is invalid.
2024-02-09 15:09:37 +00:00
Ivan Krysak d13e83163d Minor improvements 2024-02-09 15:09:37 +00:00
Alessandro Di Federico 36457a24b2 SegregateStack: support PointerToCopy arguments 2024-02-09 15:07:03 +00:00
Ivan Krysak 8a74ff94b7 ABI: prevent emission of unsupported primitives 2024-02-09 10:04:27 +01:00
Alessandro Di Federico 19c0999e65 Drop tools/link-for-translation 2024-02-09 10:04:26 +01:00
Alessandro Di Federico 346b367c19 Drop revng efa-extractcfg 2024-02-09 10:04:25 +01:00
Alessandro Di Federico d9367954a4 Convert all public strings to kebab-case 2024-02-09 10:04:24 +01:00
Alessandro Di Federico 54025b48ff s/ConvertToRawFunctionType/ConvertFunctionsToRaw/g 2024-02-09 10:04:23 +01:00
Alessandro Di Federico a9aaa8ced4 s/ToCABIFunctionType/FunctionsToCABI/s 2024-02-09 10:04:23 +01:00
Alessandro Di Federico 66b502f484 Doxygen: function prototype is optional 2024-02-09 10:04:21 +01:00
Alessandro Di Federico c73e88a8d8 Model: handle missing function prototype 2024-02-09 10:04:20 +01:00
Alessandro Di Federico 83b94026e4 RootAnalyzer: handle missing prototype 2024-02-09 10:04:20 +01:00
Alessandro Di Federico a04ccb6883 CodeGenerator: relax check on entry point 2024-02-09 10:04:19 +01:00
Alessandro Di Federico f81851c36b CodeGenerator: do not tag LLVM intrinsics 2024-02-09 10:04:19 +01:00
Alessandro Di Federico bef9efc599 EFA, importModel: handle missing prototype 2024-02-09 10:04:18 +01:00
Alessandro Di Federico 4bca30df5d InlineHelpers: fix bug preventing inlining helpers 2024-02-09 10:04:18 +01:00
Alessandro Di Federico 7112482989 Storage: fix writing to a pipe 2024-02-09 10:04:18 +01:00
Alessandro Di Federico 5fbb5ff503 Minor changes 2024-02-09 10:04:17 +01:00
Alessandro Di Federico b997e24280 PromoteInitCSVToUndef: preserve link register only 2024-02-09 09:04:25 +01:00
Alessandro Di Federico f6f542769b Convert all public strings to kebab-case 2024-02-09 09:04:25 +01:00
Pietro Fezzardi 8acf6c2f94 Allow type-less Segments in the Model 2024-02-09 09:04:23 +01:00