Commit Graph

738 Commits

Author SHA1 Message Date
Pietro Fezzardi 914ef9cc41 Better documentation for DisableStackTypeInlining 2024-06-07 17:56:14 +02:00
Lauri Vasama f4001063a7 Add note on temporary nature of scalar tuple 2024-06-05 15:07:23 +02:00
Lauri Vasama cccee1ed99 Add structured Clift type alias generation 2024-06-05 15:07:23 +02:00
Lauri Vasama d822e463e2 Use clift::ValueType instead of mlir::Type 2024-06-05 15:07:23 +02:00
Lauri Vasama 6470dd34ff Miscellaneous Clift cleanup for consistency 2024-06-05 15:07:23 +02:00
Lauri Vasama 9f7cfa183f Reorganize Clift code 2024-06-05 15:07:23 +02:00
Lauri Vasama b1afb79302 Add Clift_ prefix to all Clift tablegen defs 2024-06-05 15:07:23 +02:00
Lauri Vasama 4ebe4fb140 Rename remaining Clift type definition attributes 2024-06-05 15:07:23 +02:00
Lauri Vasama a310080fbd Rename Clift StructType and UnionType attributes 2024-06-05 15:07:23 +02:00
Lauri Vasama 8f19b5f351 Remove redundant global namespace qualifiers 2024-06-05 15:07:23 +02:00
Lauri Vasama ba58ec8edb Add import-clift-types pipe 2024-05-29 15:43:35 +02:00
Lauri Vasama ba914a1bb5 Replace MLIR container and LLVM import pipe 2024-05-29 15:43:35 +02:00
Lauri Vasama a8e2bb8c48 Add ImportModelType pass, register in clift-opt 2024-05-29 15:43:35 +02:00
Lauri Vasama 7abadd08ae Add model types to Clift MLIR import 2024-05-29 15:43:35 +02:00
Lauri Vasama f4ff27b221 Add ScalarTupleType for RawFunctionType return 2024-05-29 15:43:35 +02:00
Lauri Vasama 9f99866edd Move CliftStorage.h to lib/ 2024-05-29 15:43:35 +02:00
Lauri Vasama 6db424b02b Factor Clift type parsing out into separate files 2024-05-29 15:43:35 +02:00
Lauri Vasama 10a80de57f Fix Clift type parsing
* Allow empty parameter list for FunctionAttr.
* Allow empty field list for struct but not union.
2024-05-29 15:43:35 +02:00
Lauri Vasama 84f7926c9c Naming and reorganization for consistency 2024-05-29 15:43:35 +02:00
Lauri Vasama 1059c51292 Refactor StructTypeStorage and UnionTypeStorage 2024-05-29 15:43:35 +02:00
Lauri Vasama c24f40ad43 Add missing verify functions 2024-05-29 15:43:35 +02:00
Lauri Vasama 3a547889a3 Move struct,union get,getChecked defs to .cpp
There seem to be some issues with defining these in headers due to the
storage type being incomplete. The storage type is only defined in the
.cpp file.
2024-05-29 15:43:35 +02:00
Lauri Vasama e0eea01527 Reorder StructTypeStorage fields
Looking at the MLIR code, the order should match the order of the
parameters in get and verify.
2024-05-29 15:43:35 +02:00
Lauri Vasama 9730b00e88 Remove UnionType::verify size parameter 2024-05-29 15:43:35 +02:00
Pietro Fezzardi 2ee2577152 TypeInlineHelper: drop unused getTypeGraph method 2024-05-29 15:34:26 +02:00
Pietro Fezzardi 746cf5b55d TypeInlineHelper: rename collectStackTypes method
to collectTypesInlinableInStacks and document it.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi df9d7215b5 TypeInlineHelper: remove unnecessary members
`TypeToNumOfRefs` was used only in one method, so it can be computed
directly there on the fly.

`calculateNumOfOccurrences` doesn't need to be a method (it can be a
free function), it doesn't need to run at construction time, and it
doesn't need to return a map. So it's been moved in the `.cpp` file,
renamed to `getCrossReferencedTypes` and changed to return a set. It is
now only called when needed.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 196a15685f Rename TypeInlineHelper::findStackTypesPerFunction
to TypeInlineHelper::findTypesToInlineInStacks, which is more
descriptive of what the method actually does.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi f1fedf4e4e Drop unused TypeInlineHelper::getTypeToNumOfRefs 2024-05-29 15:34:26 +02:00
Alessandro Di Federico e22ea4b2d8 Minor changes 2024-05-29 12:23:32 +02:00
Alessandro Di Federico b05ab6ff3c Make Pipe::checkPrecondition mandatory 2024-05-21 09:44:04 +02:00
Djordje Todorovic c4eda86471 MakeModelCast: Change OpaqueFunctionsPool
Introduce new key: use TypePair instead of Type *.
2024-05-16 17:57:22 +02:00
Pietro Fezzardi 1fac9d0586 Fix mayReadMemory for stack custom opcodes
Before this commit, the mayReadMemory helper function was broken for
the two custom opcode functions used to model stack variables:
revng_stack_frame and revng_call_stack_arguments.

This means that those two functions were already considered as reading
memory, while the actually do not.

This commit fixes that, so that mayReadMemory now always properly
returns false for them.
2024-05-14 18:20:50 +02:00
Andrea Gussoni 1ceda0e8cb ASTNode: STL practice consistency 2024-05-07 14:01:56 +02:00
Alessandro Di Federico 31344a3270 Add missing includes 2024-05-03 21:55:33 +02:00
Pietro Fezzardi 8b0f4e035c RestructureCFG: update deduplicated dummy nodes
Before this commit, it could happen that some duplicated dummy node
(used to mark backedges) could be left lingering in wrong regions when
collapsing a regions, if they were first iteration outlined.

This commit fixes the problem, by collecting them and letting
`updateNodes` take care of them, removing them from the containing
region and all its parents.
2024-03-25 18:08:35 +01:00
Pietro Fezzardi 454e38e4ff RestructureCFG: handle retreating from SetNodes 2024-03-25 18:08:35 +01:00
Pietro Fezzardi 05cc20cb6e Rename MallocLike Tag to ReturnsPolymorphic
Also add this Tag to the LocalVariable opcode who was missing it.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi ed88c6b459 Use LLVM MemoryEffects in hasSideEffects 2024-03-19 09:44:00 +01:00
Pietro Fezzardi 206936f1c0 Drop redunant ReadsMemory and WritesMemory Tags
Over time, these tags have shifted to basically coincide with the Copy
and Assign tags. There's no need for them anymore they just make the
code more verbose and less straightforward.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 83d56fb40b Update hasSideEffects helper function
Before this commit the `hasSideEffects` helper function was only a stub,
that was never updated to be aware of recent FunctionTags representing
custom opcodes without side-effects.

This commit updates it, so that now it is less aggressive in marking
harmless stuff as side-effectful.
2024-03-19 09:44:00 +01:00
Andrea Gussoni cf43b9e92d GenerateAst: remove weaved switch handling
Remove the special handling for the weaved `switch`es.
2024-03-15 14:27:00 +01:00
Andrea Gussoni 95f9bb32cb GenerateAst: add SwitchBreakNode::removeDefault 2024-03-15 14:27:00 +01:00
Andrea Gussoni 8fe291a62b GenerateAst: use llvm::find_if and llvm::count 2024-03-15 14:27:00 +01:00
Andrea Gussoni 6c8d963f69 RestructureCFG: Reorganize debug graphs
Various improvements to the debug graphs for `restructure-cfg` and
`beautify`:
- Normalize casing and syntax of debug graphs.
- Improve the graph folders name and layout.
- Implement `CFGDumper` and `ASTDumper` for when we need a serialization
  with incremental indexes.
- Remove old and stale graph serializations.
2024-03-11 19:08:34 +01:00
Andrea Gussoni d863dd1542 RegionCFGTreeImpl: do not reprocess conditionals
Do not re-enqueue conditional nodes a for combing, when duplicating a
conditional.

This can be done in such way, thanks to the property that we process
conditional nodes in postorder. Therefore, if conditional node A causes
the duplication of, say, node B, we have the guarantee that such node B
has already been processed by the combing. Therefore, the clone of node
B, say node B', should not be reprocessed for combing.
2024-03-11 18:51:03 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03: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
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
Alessandro Di Federico f6f542769b Convert all public strings to kebab-case 2024-02-09 09:04:25 +01:00