Commit Graph

6113 Commits

Author SHA1 Message Date
Pietro Fezzardi 132adeecd5 Add PeepholeOptimization pass
This pass is dedicated to applying a bunch of peephole optimizations
that are useful for decompilation and haven't been implemented in LLVM
for whatever reason.

At the moment it only runs an optimization that tries to reduce the uses
of incoming values of PHINodes, under very specific condidtions, which
enables emitting less LocalVariables.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 37340a91a7 Don't skip non-isolated Function in FunctionPass
Before this commit, many passes in revng-c were skipping over
non-isolated functions.

Now revng-pipeline takes care of removing non-isolated functions so that
check can be omitted everywhere.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 70c8ae48ff Retire MarkAssignment for SwitchToStatements 2024-03-19 09:44:00 +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
Pietro Fezzardi 76739c2811 ExitSSA: better placement for StoreInst
This commits changes the ExitSSAPass to ensure that StoreInst are placed
ASAP, close to the computation of the incoming Values of the replaced
PHINode.
This generates IR that typically yields less local variables in
SwitchToStatements.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 6b022c9d30 Make ExitSSA deterministic 2024-03-19 09:44:00 +01:00
Pietro Fezzardi 847cad3422 MakeSegmentRef: fix checks on pointer size 2024-03-19 09:44:00 +01:00
Pietro Fezzardi df3bd470a1 Enforce determinism on CSV handling
Various parts of revng replace `llvm::GlobalVariable`s representing CSVs
with Allocal/Load/Store. In particular, these are PromoteCSV,
RootAnalyzer and PromoteGlobalToLocalVars.

Before this commit, those places were sloppy when replacing CSVs with
Alloca/Load/Store, and did that iterating on a container sorted by
pointers. This caused Alloca/Load/Store to be emitted in different order
accross runs, which in turn caused more non-determinism down the
pipeline.

This commit fixes the non-deterministic behavior, sorting CSVs based on
their names, which should always be present and deterministic.
2024-03-19 09:43:59 +01:00
Pietro Fezzardi 1baec8ff7b Drop old MonotoneFramework 2024-03-19 09:43:59 +01:00
Pietro Fezzardi 2cd7777030 MFP: add SetIntersectionLattice 2024-03-19 09:43:59 +01:00
Alessandro Di Federico cf3072d0c5 Merge branch 'feature/avoid-excessive-layout-usage' 2024-03-18 19:32:36 +01:00
Ivan Krysak 89b454a224 EFA: improve robustness against non-existent FSO 2024-03-18 19:32:35 +01:00
Ivan Krysak 13cc649226 test-model-diff: fix temporary directory usage 2024-03-18 19:32:35 +01:00
Ivan Krysak 64eb2adb7c Minor improvements 2024-03-18 19:32:34 +01:00
Ivan Krysak 0692ef0828 Doxygen: be extra explicit about layout usage 2024-03-18 19:32:34 +01:00
Ivan Krysak d1d97fe47e PTML: fix doxygen stack indication 2024-03-18 19:32:34 +01:00
Ivan Krysak 6b7650276e EFA: split importModel into multiple methods 2024-03-18 19:32:34 +01:00
Ivan Krysak 5afba1382c EFA: update clobbered register list computation 2024-03-18 19:32:34 +01:00
Ivan Krysak 7e08c341e9 EFA: update preserved register diffing 2024-03-18 19:32:34 +01:00
Ivan Krysak 2aad45f452 EFA: reorder prototype-based summary importer
This lets up cleanly "bail out" after only some of the computation
is done. This way we avoid reading information we don't really use
from the model based on who is the specific user of the oracle.
2024-03-18 19:32:34 +01:00
Ivan Krysak 78d0802f74 EFA: turn importPrototype into a helper struct 2024-03-18 19:32:34 +01:00
Ivan Krysak 024e5b931c STLExtras: introduce revng::to helper 2024-03-18 19:32:34 +01:00
Ivan Krysak 9c9e642589 EnforceABI: stop using Layout 2024-03-18 19:32:34 +01:00
Ivan Krysak b1c2683b87 EFA: stop using Layout 2024-03-18 19:32:34 +01:00
Ivan Krysak c9c4d5c8b6 Lift: stop using Layout 2024-03-18 19:32:34 +01:00
Ivan Krysak dc16217f6d Layout: introduce usedRegisters helper 2024-03-18 19:32:34 +01:00
Ivan Krysak 816b49c09f TrackingContainer: introduce asVector helper 2024-03-18 19:32:34 +01:00
Ivan Krysak 0d5c93ed36 Distributor: add nextPositionBasedIndex 2024-03-18 19:32:34 +01:00
Ivan Krysak 408c37caf2 Layout: introduce finalStackOffset helper 2024-03-18 19:32:34 +01:00
Ivan Krysak 54fd2295ac Layout: introduce calleeSavedRegisters helper 2024-03-18 19:32:34 +01:00
Ivan Krysak 58e5fffb14 Layout: rework dump 2024-03-18 19:32:34 +01:00
Ivan Krysak 116510cd13 Layout: clean ArgumentKind enum up 2024-03-18 19:32:34 +01:00
Alessandro Di Federico 5cf07b5d18 Merge branch 'feature/basic-disassembly-configuration' 2024-03-18 18:22:00 +01:00
Ivan Krysak cb113db124 PromoteSP: stop using Layout 2024-03-18 17:24:01 +01:00
Ivan Krysak 5894201920 Yield: update model-tutorial.md 2024-03-18 17:23:07 +01:00
Ivan Krysak f2ab83489c Yield: fix missing delay slots
When converting to PTML half of the delay slot logic
2024-03-18 11:40:32 +00:00
Ivan Krysak ff59c24a3f Yield: set CommentFontSize to 0
Since VSCode does not display instruction comments, accounting for
them was interfering with the graph rendering.
2024-03-18 11:40:32 +00:00
Ivan Krysak 44e5328477 Yield: add explicit directive support 2024-03-18 11:40:32 +00:00
Ivan Krysak ff436f36bf SortedVector: add an iterator constructor 2024-03-18 11:02:21 +00:00
Ivan Krysak 346cb498d3 Yield: make disassembly output objdump-like 2024-03-18 11:02:21 +00:00
Ivan Krysak 77fb7e6e5b Yield: introduce BasicBlockPrefix option 2024-03-18 10:58:55 +00:00
Ivan Krysak e5328290c6 Yield: reorder disassembly processing
This commit moves stuff around to enforce complete information being
present by the time the "Internal" assembly output is ready.

Because of that, the "Internal" format needed to change, now it uses
tag representation close to PTML as opposed to the one close to LLVM's
used before now.
2024-03-18 10:58:52 +00:00
Ivan Krysak 948d905752 Add PrintFullMetaAddress configuration option 2024-03-18 11:58:11 +01:00
Ivan Krysak 4d7785f0bb Yield: remove unused 'plain' assembly style
When needed similar results can be achieved using `GenerateTagLessPTML`
option of the `PTMLBuilder`.
2024-03-18 11:58:11 +01:00
Ivan Krysak e2018fa1c3 MetaAddress: add partial serialization option 2024-03-18 11:58:11 +01:00
Ivan Krysak 86fdb19b9f MetaAddress: pull separator into the header 2024-03-18 11:58:11 +01:00
Ivan Krysak 001afd7eea PermutationSelection: rethink iteration count
This change slightly improves the performance on slow to medium graphs
while leaving the performance on somewhat big ones untouched and
making the extremely big ones a lot worse. It also greatly improves
performance in the general case.
2024-03-18 11:58:11 +01:00