Commit Graph

6113 Commits

Author SHA1 Message Date
Matteo Giordano 0ec73686f3 Fixed typos in GeneratedIRReference.rst 2021-09-01 16:34:25 +02:00
Filippo Cremonese 2341b37832 Release build: suppressed unused typedefs warning
Builds in release mode failed because of unused local typedefs defined
in headers included from boost. This commit disables that specific
error.
2021-09-01 16:33:33 +02:00
Ivan Krysak fbf90f8b17 Implement revng::SmallMap::contains 2021-09-01 16:32:56 +02:00
Andrea Gussoni 16e7b2f051 RegionCFG: Improve moveEdgeTarget
`moveEdgeTarget` and `moveEdgeSource` now directly modify the
successor/predecessor field in place in the edge data structure, instead
of extracting and reinserting later the edge.

This avoid a subtle bug, found in the `createTile` helper function, that
caused the swap of a `then` and `else` branch during a tile creation
step, that consequently broke the semantics in the recovered GHAST.
2021-09-01 15:11:06 +02:00
Pietro Fezzardi a2a29c7942 Fix missing linking with revng and LLVM libraries 2021-08-31 12:30:04 +02:00
Pietro Fezzardi f057441ce8 Fix linking 2021-08-20 11:21:04 +02:00
Pietro Fezzardi 470cd6a602 Merge branch 'fix/conditional-node-successor' into next-develop 2021-08-19 18:51:57 +02:00
Andrea Gussoni 55c620ab31 RegionCFGTree: refactor connectContinueNode
THe creation and connection of continue nodes is now down in the
population of the collapsed region, avoiding external methods.
2021-08-19 18:51:24 +02:00
Andrea Gussoni 4ce2189bec RegionCFGTree: remove copyNodesAndEdgesFrom 2021-08-19 18:51:24 +02:00
Andrea Gussoni 7323cecec1 RestructureCFG: improve break node creation
Break node creation is now improved to avoid edge index swapping that
can cause inversion of conditions later on in the decompilation
pipeline.

To do this, the creation and connection of the break nodes is done
during the bulk insertion of nodes in a collapsed region.
2021-08-19 18:51:14 +02:00
Andrea Gussoni 866ab7cbed CDecompilerAction: fix expression negation
The `negateExpr` function incorrectly changed the `OpCode` of a binary
comparison, resulting in not intended side effects.
2021-08-19 18:50:39 +02:00
Andrea Gussoni 3bb3437466 RegionCFG: Add successor index in RegionCFG dots 2021-08-19 18:50:34 +02:00
Pietro Fezzardi 61705691d2 Merge branch 'feature/dla-fix-singlechild' 2021-07-27 12:02:40 +02:00
Alvise de Faveri a0f95e0370 Modify CollapseSingleChild to allow single members
* Inheritance straight lines are now collapsed by CollapseSingleChild
* Don't collapse if parent has more than one parent or if the child has
more than one parent
* Allow the possibility to construct single-member struct: if this
struct is inherited by many other structs, "flattening" the struct is not
the most sensible thing to do, since inheritance information is something
we want to preserve in these cases.
2021-07-27 11:59:48 +02:00
Alvise de Faveri d819437aa3 Add UT for all DLA steps 2021-07-23 18:11:30 +02:00
Alessandro Di Federico 92c7ed0129 Merge branch 'feature/model-type-system' 2021-07-22 08:46:30 +02:00
Alessandro Di Federico a5600a68ab TupleTree: improve support for 0-sized tuples 2021-07-21 18:22:58 +02:00
Alessandro Di Federico bf55034fa6 Support deserializing empty TupleTreeReference 2021-07-21 18:22:58 +02:00
Alessandro Di Federico fd30d3de42 Import the model's type system
This commit introduces the type system of the model along with several
various other improvements to the model and its users.

* Introduce the type system.
* Introduce possibility to tag certain fields in the model as to be
  optional during YAML serialization.
* All the `Name` fields have been replaced in favor of `CustomName` plus
  a `name` method that will use `CustomName` if available, or an
  automatically generated name otherwise.
* Make TupleTreeReferences behavior more robust: now you either need to
  have a valid pointer to `Root` and a `Path` or be default constructed
  (`nullptr` for `Root` and an empty `Path`). Any other configuration is
  invalid.
* The type system introduces `RawFunctionType`: this superseds the
  previous way in which we were specifying arguments and return
  values. Users of such information have been updated accordingly.
2021-07-21 18:22:58 +02:00
Alessandro Di Federico 0f8fa271d9 TupleTree: reduce INTROSPECTION responsibilities
This commit also introduces support for optional YAML serialization of
fields.
2021-07-21 18:19:45 +02:00
Alessandro Di Federico a546ac2a37 Introduce model::Register::getSize 2021-07-21 18:19:45 +02:00
Alessandro Di Federico 69367669d7 model::Register: enable as KOC key 2021-07-21 18:19:45 +02:00
Pietro Fezzardi 10d1eab7f4 Decompiler: update to new model APIs 2021-07-21 11:09:28 +02:00
Pietro Fezzardi e1ab2ff553 ASTBuildAnalysis.cpp: disable array accesses 2021-07-21 10:48:06 +02:00
Pietro Fezzardi 88ade5e105 Handle non-decreasing nested AddRecs
These may happen in nasty functions like memchr, where you have a loop
pre-header iterating over single bytes, a loop iterating over 4 bytes,
and finally the loop exit iterating over single bytes again.

Now we stop at the first non-decreasing nested AddRec.
2021-07-21 10:48:06 +02:00
Pietro Fezzardi f2dd2d89de ASTBuildAnalysis: improve logging 2021-07-21 10:48:06 +02:00
Pietro Fezzardi c994dc0b44 ASTBuildAnalysis: drop assertion for handled case 2021-07-21 10:48:06 +02:00
Pietro Fezzardi 81cb8422ad ASTBuildAnalysis: build member access expressions 2021-07-21 10:48:06 +02:00
Pietro Fezzardi 878b0a8075 Enable --sroa-aggressive-phis-selects for DLA 2021-07-21 10:46:30 +02:00
Pietro Fezzardi ae0095e90a DLA: handle Values with unknown Layouts 2021-07-20 15:20:53 +02:00
Alessandro Di Federico 56644b8512 Move model::Register in its own file 2021-07-15 13:50:53 +02:00
Pietro Fezzardi 8fa8ca2d03 Rework getWriteableModel to return a TupleTree
The previous design returned a model::Binary &, which did not allow
users writing the model to properly initialize cross references between
different parts of the model.
2021-07-15 13:30:25 +02:00
Alessandro Di Federico b4929b431c Drop IsTupleEnd concept 2021-07-15 13:30:25 +02:00
Alessandro Di Federico 6d10581163 Whitespace and other minor changes 2021-07-15 13:30:25 +02:00
Alvise de Faveri 4eb50d0bb5 Add Unit Test for DLACollapseSingleChild 2021-06-30 17:50:12 +02:00
Alvise de Faveri c1e4b940d0 Add CollapseSingleChild step to DLA 2021-06-30 17:50:12 +02:00
Pietro Fezzardi 6efc356c47 Drop dependency on GCBI and BlockType
During combing, GCBI's BlockType was used to detect unexpectedPC and
anyPC. This method is does not work anymore (since revng started
dropping such info from isolated functions and replacing that with
llvm::unreachable instructions).

This commit drops the dependency on GCBI and BlockType, and starts
detecting blocks to inline by simply looking at their terminator. If
it's an llvm::unreachable, the block is detected as inlineable.
2021-06-30 10:38:00 +02:00
Alvise de Faveri 47db3fdb11 Promote AccessSizes to full-fledged TS nodes
While doing thie, also drop `printAccessNode()` from DLA DebugPrinter.

The information about which LLVM instruction originated a given access
node is already available in the csv generated by the `dla-accesses-log`
logger.
2021-06-25 18:07:17 +02:00
Pietro Fezzardi d09c7c6ab3 Handle inheritance in with interfering children
Until now, in makeLayout, inheritance edges were ignored when the
children were interfering.
Now the inheritance edges are treated as if they were instance edges at
offset 0.
2021-06-24 17:24:59 +02:00
Pietro Fezzardi 18bff2dba1 DLAMakeLayouts.cpp: drop unused variable 2021-06-24 17:24:59 +02:00
Pietro Fezzardi 6a2e130ec6 Move openFunctionFile to new Utils library 2021-06-21 14:15:30 +02:00
Alvise de Faveri bfdef657f2 Move DLA files to separate folder 2021-06-18 18:24:04 +02:00
Alvise de Faveri 105edb69a3 DLA: Decouple DLATypeSystem from LLVM Values
- Remove `CreateInterProceduralTypes` and `CreateIntraProceduralTypes`
  from the StepManager and put them in a separate
  `DLATypeSystemLLVMBuilder` object that is in charge of initializing
  the DLATypeSystem graph.
- Remove `MakeLayouts` from the StepManager and split into two free
  functions: `makeLayouts` and `makeLayoutMap()`
- Remove all LLVM-related stuff (Module, LayoutTypePtrs and mappings
  between these and DLATypeSystemNodes) from DLATypeSystem
- Add an IntEqClasses member to DLATypeSystem, to use to map between
  LayoutTypePtrs and Layouts
- Add a TSDebugPrinter object inside the DLATypeSystem, which by default
  prints only IDs
- Define an LLVMTSDebugPrinter inside DLATypeSystemBuilder which
  overrides the default printer's behavior, printing LLVM-related info.
- Add the possibility to dump into a .csv file the bindings between
  Nodes in the TypeSystem and `llvm::Value`s
2021-06-18 18:12:14 +02:00
Alessandro Di Federico 952602c6db Merge branch 'feature/llvm-12' 2021-06-14 23:04:35 +02:00
Pietro Fezzardi 1047f50f62 Silence -Wvoid-pointer-to-int-cast in support.c 2021-06-14 23:04:02 +02:00
Pietro Fezzardi 67eaaab045 JumpTargetManager: enable InstCombine(true)
This fixes the latest failing tests after upgrading to llvm-12.
2021-06-14 23:04:02 +02:00
Pietro Fezzardi b96fbd091d Fix check-conventions with clang-format-12 2021-06-14 23:04:02 +02:00
Pietro Fezzardi 6f7de910a6 Enable warning -Wunused-local-typedefs 2021-06-14 23:04:02 +02:00
Pietro Fezzardi 7735879fa0 Enable warning: -Wdeprecated-enum-enum-conversion
This was disabled because it triggered errors when compiling with older
versions of llvm-12 and -Werror.
With llvm-12 this needed anymore, so we can re-enable it
2021-06-14 23:04:02 +02:00
Pietro Fezzardi 71c79461d8 MaterializedValue: fix comparison between APInt
Comparing APInt requires them to have the same BitWidth.
2021-06-14 23:04:02 +02:00