Commit Graph

2042 Commits

Author SHA1 Message Date
Pietro Fezzardi e1b5541462 DLA: depotentiate SimplifyInstanceAtOffset0
The DLAStep SimplifyInstanceAtOffset0 now only triggers if the parent
node has the child-at-offset-0 node as its only successor, or when the
child-at-offset-0 doesn't have other predecessors.

Doing this guarantees that it's impossible for another predecessor of
the child-at-offset-0 to start seeing memory accesses that were
initially relative to the parent.

This condition is slightly more restrictive than the previous one, but
it takes into consideration some far reaching consequences.
If SimplifyInstanceAtOffset0 aggressively like we did before, DLA can
end up inferring types in some memory locations, like executable
segments, for which there aren't clues in the binary.
This isn't bad per se, but if DLA does that, the newly recovered type is
identified as non-executable data, causing misdecompilation because
rev.ng doesn't decompile memory regions that it understands as non
executable.

This commit, making SimplifyInstanceAtOffset0 less aggressive, makes it
play better with the rest of the assumptions of the decompilation
pipeline.

It also relaxes a decompilation test that was previously working by
chance and that was effectively beyond the current expressive power of
reasoning for DLA at the moment.
2024-07-05 00:43:45 +02:00
Pietro Fezzardi 8311efb21c DLA: re-enable DeduplicateFields after fixing it 2024-07-05 00:43:35 +02:00
Pietro Fezzardi 99d4c0283a DLA: fix DeduplicateField traversal and comparison
Before this commit the breadth-first traversal was more convoluted and
it used a broken criterion for bailing out, resulting sometimes in
considering a pointer edge as if it was an instance edge.
This in turn caused bugs to the point of the DLA Graph failing
verification.

This commit rewrites and simplifies the main traversal and comparisons
in DeduplicateField to make them robust against these bugs.
2024-07-05 00:43:35 +02:00
Pietro Fezzardi 19d43cde1d Partially re-enable end-to-end tests
End-to-end tests were disabled due to a bug in ModelToHeader that caused
the decompiled C header with the types not to be recompilable in some
cases.

However, the commit that disabled the tests was too aggressive, because
the only part that needed to be disabled was the part of the tests that
actually recompiled the C code.

This commit re-enables the end-to-end tests except for the recompilation
part, that will be re-enabled after the bug in ModelToHeader is fixed.
2024-07-04 02:56:31 +02:00
Pietro Fezzardi 4562232281 Merge branch 'feature/demo-recon' 2024-06-27 17:34:19 -04:00
Pietro Fezzardi 521baf38e8 PTML: honor GeneratePlainC 2024-06-27 17:30:56 -04:00
Pietro Fezzardi dfe3f4cb47 Rename revng C headers for decompiled code
Strip away the 'revng-' prefix from the filename.
2024-06-27 17:26:18 -04:00
Pietro Fezzardi d72139357f Add DecompileToDirectoryPipe
This pipe decompiles all the C code in a single directory, packaged up
as a .tar.gz file.
2024-06-27 17:26:18 -04:00
Pietro Fezzardi 8a95a0b9c9 HelpersToHeader: enable printing plain C 2024-06-27 17:14:28 -04:00
Pietro Fezzardi 2b9bcc0260 Backend: enable decompiling as plain C 2024-06-27 17:14:28 -04:00
Pietro Fezzardi a12b621832 Add CleanupIRPass 2024-06-27 17:14:28 -04:00
Alessandro Di Federico 14db4fd67f Merge branch 'feature/drop-qualifiers' 2024-06-27 11:08:21 +02:00
Ivan Krysak 95cfa4785f MakeModelCastPass: remove an obsolete if branch 2024-06-27 11:07:02 +02:00
Ivan Krysak 74f56bcd93 Introduce a broken debug info removal pass 2024-06-27 11:07:02 +02:00
Ivan Krysak 31edf40695 ImplicitModelCastPass: better constness handling 2024-06-27 11:07:02 +02:00
Ivan Krysak 5ed120cdc9 ImplicitModelCastPass: extend logging 2024-06-27 11:07:02 +02:00
Ivan Krysak 185fc68097 PTML: fix the direct array data usage 2024-06-27 11:07:02 +02:00
Ivan Krysak aed53c943c linked-lists: re-enable compute return value 2024-06-27 11:07:02 +02:00
Ivan Krysak 0542be1b23 Add an array emission test 2024-06-27 11:07:02 +02:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00
Ivan Krysak 504928d886 Minor improvements 2024-06-27 11:07:01 +02:00
Ivan Krysak c2b4fb70bb Model: rename TypePath to DefinitionReference 2024-06-27 11:07:01 +02:00
Ivan Krysak 3705906074 Model: rename Type into TypeDefinition 2024-06-27 11:07:01 +02:00
Alessandro Di Federico d14b4905e7 Merge branch 'feature/pipeline-revng-passes' 2024-06-27 10:17:44 +02:00
Alessandro Di Federico 2aa4812ca0 end-to-end.yml: disable check-decompiled-c
This is a temporary change.
2024-06-27 10:13:49 +02:00
Pietro Fezzardi 85340c8d84 ModelToHeader: disable type inlining by default
This is due to the fact that type inlining currently is broken in some
corner cases involving recursive types.
The bugs are caused by the fact that TypeInlineHelper uses its own
custom graph instead of using the DependencyGraph used by ModelToHeader,
causing different decisions about the order of emission of types.
As a result, the generated C types are not valid C, and they fail to
compile because a field of a struct has a type that is defined later
than its use.

After refactoring TypeInlineHelper to use DependencyGraph like
ModelToHeader, this can be reverted.
2024-06-26 12:21:58 +02:00
Pietro Fezzardi fc02a98aa3 DLA: disable DeduplicateFields
The DLAStep has bugs that are preventing other useful features to be
merged.
2024-06-26 12:21:58 +02:00
Alessandro Di Federico aaba2f7d0f segregate-stack-accesses.yml: adopt --debug-names 2024-06-26 12:21:58 +02:00
Alessandro Di Federico f231e19a5f decompilation.yml: remove test duplication 2024-06-26 12:21:58 +02:00
Alessandro Di Federico a7ec300b16 MLIRContainer::mergeBack: only purge definitions 2024-06-26 12:21:58 +02:00
Alessandro Di Federico 988af25a7d Adopt UniquedBy* FunctionTags for deduplication 2024-06-26 12:21:58 +02:00
Alessandro Di Federico 5186a58053 s/FunctionMetadata/ControlFlowGraph/ 2024-06-18 17:56:24 +02:00
Alessandro Di Federico a6759b9231 LLVMIRForMLIR: name structs with growing numbers 2024-06-18 17:56:24 +02:00
Alessandro Di Federico 61358cd862 Clift: adopt revng pipe for unit testing 2024-06-18 17:56:24 +02:00
Alessandro Di Federico 3dc8cf5e84 Minor changes 2024-06-18 17:56:24 +02:00
Pietro Fezzardi b6c64c3d5a Merge branch feature/fix-dla-accesses-hierarchical 2024-06-18 11:20:26 +02:00
Pietro Fezzardi 4fc37fe7eb DLA: improve ArrangeAccessesHierarchically logs 2024-06-18 11:19:50 +02:00
Pietro Fezzardi 64d41a9b1d DLA: fix ArrangeAccessesHierarchically iteration
Before this commit the code was wrong in 2 ways:
- if failed to iterate on children, because it iterated a range that was
  effectively [begin, begin) instead of [begin, end)
- the update of the ARootNext iterator in the loop was broken, but it
  was impossible to realize that since the loop was never taken

This commit fixes both these intertwined problems.
2024-06-18 11:19:50 +02:00
Pietro Fezzardi e44eeb6345 Merge branch feature/weaken-clift-fieldattr-verify 2024-06-18 11:17:58 +02:00
Pietro Fezzardi 9d24e9372d Clift FieldAttr::verify: improve debug message 2024-06-18 11:17:41 +02:00
Pietro Fezzardi b9ef4b205c Clift parseCompositeType: improve debug messages 2024-06-18 11:17:18 +02:00
Pietro Fezzardi 8f81e3ff9a Temporarily remove recursive class type unit test
The FieldAttr::verify checking for non-complete field types was testing
for completeness too eagerly and was removed. Forbidding class type
recursion without indirection is desirable, but needs to be done less
eagerly. A new unit test to validate this via clift::ModuleOp::Verify
needs to be created to replace this one.
2024-06-18 11:14:10 +02:00
Lauri Vasama 6803317f56 Remove type completeness check in FieldAttr verify 2024-06-13 14:03:28 +03:00
Pietro Fezzardi cf41471d25 Merge branch 'feature/refactor-type-inlining' 2024-06-10 17:41:40 +02:00
Pietro Fezzardi 4549e71a22 Add TODO for future refactoring 2024-06-10 17:41:02 +02:00
Pietro Fezzardi 7e44777c98 ModelToHeader: reduce lifetime of TypeInlineHelper 2024-06-07 17:59:06 +02:00
Pietro Fezzardi 84a40d0239 TypeInlineHelper: clean up members and methods 2024-06-07 17:59:06 +02:00
Pietro Fezzardi d82255b3fa Don't inline pointer types
Support for them was subtly bugged in case of recursive types, and
properly supporting this is not trivial.
We disable them for now.
2024-06-07 17:59:06 +02:00
Pietro Fezzardi 7a38a257b9 Refactor TypeInlineHelper::findTypesToInline
This change is a preparation for further decoupling of the
TypeInlineHelper from its custom dependency graph type, to try and reuse
the DependencyGraph used in ModelToHeader.
2024-06-07 17:59:06 +02:00
Pietro Fezzardi e052dee40f Drop isCandidateForInline 2024-06-07 17:59:06 +02:00