Commit Graph

3168 Commits

Author SHA1 Message Date
Pietro Fezzardi d91ca93b5b MakeEnvNull: fix env substitution
Before this commit, `MakeEnvNullPass` was substituting uses of `env`
with uses of `nullptr`.
This operation was introducing undefined behavior, and subsequent
optimizations were allowed to mark BasicBlocks where it occured as
unreachable, eventually leading to their wrong removal.

This commit fixes the substitution, properly replacing loads from `env`
with `nullptr`.
This should never cause undefined behavior anymore, because the results
from load from `env` is never referenced in isolated functions.
2021-01-22 17:23:55 +01:00
Alessandro Di Federico 54ea92cfec Introduce GCBI::programCounterHandler 2020-12-31 14:37:53 +01:00
Alessandro Di Federico d3247870f0 Reorganize ProgramCounterHandler construction 2020-12-31 14:37:53 +01:00
Antonio Frighetto 02b3a24463 Jump to dispatcher when location is invalid
Replace a call to `abort` with a branch to `dispatcher` when the
callee is unknown or invalid (namely, it is always treated as an
indirect call).
2020-12-31 14:17:30 +01:00
Pietro Fezzardi 7ff24ac761 GCBI: remove assertion on Dispatcher != nullptr
This assertion was executed in the `runOnModule` method of the GCBI
pass, but it is too strict.

Asserting that Dispatcher != nullptr during the execution of the pass
prevents the pass from successfully running on a Module without a
Dispatcher.
This is unfortunate, because some passes that depend on GCBI in revng-c
actually do that. They do so because they are not really interested in
the Dispatcher at all. They only use GCBI to access information on the
Stack Pointer.

In fact, the check for Dispatcher being != from nullptr is already
performed also in the `dispatcher()` method which is the sane thing to
do. This commit removes the assertion from the `runOnModule` method and
leaves it in the `dispatcher` method.
This allows to run the pass successfully even on a Module without the
Dispatcher, while not changing the contract of this pass (i.e. that when
you call the `dispatcher` method you get a nonnull pointer).
2020-12-29 14:51:38 +01:00
Pietro Fezzardi 31a63a1416 [TypeShrinking] Apply check-revng-conventions 2020-12-23 02:27:04 +01:00
Qian Matteo Chen 0b2ba53560 [TypeShrinking] Add type shrinking to pipeline 2020-12-23 02:24:03 +01:00
Qian Matteo Chen 61c7f4cf0f [TypeShrinking] Fix use after destructor 2020-12-23 02:23:32 +01:00
Qian Matteo Chen 04085ecd99 [TypeShrinking] Fix styling issues 2020-12-23 02:23:00 +01:00
Qian Matteo Chen 750b326d24 [TypeShrinking] Ensure coherence of input liveness
with result size.
2020-12-23 02:22:28 +01:00
Qian Matteo Chen 007119af91 [TypeShrinking] Fix comment capitalization 2020-12-23 02:21:56 +01:00
Qian Matteo Chen 04a7ff86b2 [TypeShrinking] Don't shrink to booleans 2020-12-23 02:20:53 +01:00
Qian Matteo Chen 232c1596ce [TypeShrinking] Split passes in two 2020-12-23 02:20:21 +01:00
Qian Matteo Chen 568f13e48d [TypeShrinking] Document transfer functions 2020-12-23 02:19:18 +01:00
Qian Matteo Chen bb8e98bfcb [TypeShrinking] Refactor using ranges .at() 2020-12-23 02:10:16 +01:00
Qian Matteo Chen ee7917faa1 [TypeShrinking] Iterate over instructions 2020-12-23 02:07:34 +01:00
Qian Matteo Chen a37ef2f2bd [TypeShrinking] Move small definitions in header 2020-12-23 02:03:46 +01:00
Qian Matteo Chen b0a3c4007c [TypeShrinking] Uppercase arguments 2020-12-23 02:00:51 +01:00
Qian Matteo Chen 5c02c41e12 [TypeShrinking] Use dyn_cast instead of isa + cast 2020-12-23 01:57:20 +01:00
Qian Matteo Chen b0542bbb64 [TypeShrinking] Use concepts in MFP implementation 2020-12-23 01:54:10 +01:00
Qian Matteo Chen 4a0b124464 [TypeShrinking] Remove java like constructor 2020-12-23 01:51:07 +01:00
Qian Matteo Chen 948c1c6bd6 [TypeShrinking] Reformat CMakeLists.txt 2020-12-23 01:48:04 +01:00
Qian Matteo Chen 923debe1a6 [TypeShrinking] Use std::min and std::max 2020-12-23 01:44:59 +01:00
Qian Matteo Chen b371c27089 [TypeShrinking] Remove unused header 2020-12-23 01:42:05 +01:00
Qian Matteo Chen 5ee2cdf004 [TypeShrinking] Refactor code
- Use uint32_t
- Define Top as uin32_t max
- Fix copyright notice
- Use using namespace llvm in cpp files
- Change hasSideEffects to isDataFlowSink
- Outline isAddLike
- Add option to ignore certain analysis results
2020-12-23 01:38:52 +01:00
Qian Matteo Chen 247d44d29b [TypeShrinking] Add forward declaration 2020-12-23 01:35:08 +01:00
Qian Matteo Chen bd613d5c7f [TypeShrinking] Remove unused files 2020-12-23 01:29:43 +01:00
Qian Matteo Chen 4565edc4fb [TypeShrinking] Move DataFlowGraph.h to local dir 2020-12-23 01:24:37 +01:00
Qian Matteo Chen a0e45760c5 [TypeShrinking] Add more transfer functions 2020-12-23 01:21:03 +01:00
Qian Matteo Chen 479298d60c [TypeShrinking] Implement type shrinking pass 2020-12-23 01:17:55 +01:00
Qian Matteo Chen 8667f64081 [TypeShrinking] Remove initial defuse poc pass 2020-12-23 01:13:07 +01:00
Qian Matteo Chen 31b8ed7b14 [TypeShrinking] Move BitLiveness.h to local folder 2020-12-23 01:03:56 +01:00
Qian Matteo Chen ba099220da [TypeShrinking] Add type shrinking mvp 2020-12-23 00:14:03 +01:00
Qian Matteo Chen 86cd1d5505 [TypeShrinking] Add and fix copyright notices 2020-12-22 20:08:06 +01:00
Qian Matteo Chen cccd462b64 [TypeShrinking] Add example of MonotoneFramework 2020-12-22 18:33:24 +01:00
Qian Matteo Chen 60c4e59c6b [TypeShrinking] Refactor MFP to use GraphTraits 2020-12-22 18:30:33 +01:00
Qian Matteo Chen 6054d08645 [TypeShrinking] Use llvm::cast 2020-12-22 18:22:45 +01:00
Qian Matteo Chen 3d8793fa2a [TypeShrinking] Move implementation to cpp file 2020-12-22 18:19:43 +01:00
Qian Matteo Chen 8a7813fabf [TypeShrinking] Add BitSet using directive 2020-12-22 18:00:49 +01:00
Qian Matteo Chen be3d67026f [TypeShrinking] Assert success of cast 2020-12-22 17:21:08 +01:00
Qian Matteo Chen f6978a9879 [TypeShrinking] Move using and pass registration 2020-12-22 17:18:20 +01:00
Qian Matteo Chen 75b77af481 [TypeShrinking] Refactor iterator uses 2020-12-22 17:15:11 +01:00
Qian Matteo Chen 25f4a112c4 [TypeShrinking] Explicit auto * for GraphNode 2020-12-22 17:12:05 +01:00
Qian Matteo Chen 473982966b [TypeShrinking] Combine isLess and areEqual 2020-12-22 17:04:55 +01:00
Qian Matteo Chen df93bd474b [TypeShrinking] Add newline at the end of the file 2020-12-22 17:01:26 +01:00
Qian Matteo Chen 7feebad315 [TypeShrinking] Add implementation of MFP
See Principles of Program Analysis, Springer 2005, p 75
2020-12-22 16:55:16 +01:00
Qian Matteo Chen c1d144f186 [TypeShrinking] Add pass to print dataflow edges 2020-12-22 16:39:38 +01:00
Pietro Fezzardi ebe43602ac New FilterForDecompilation passes
This commits adds two passes
- FilterForDecompilationFunctionPass deletes the body of a Function if
  it's not a isolated function produced by revng
- FilterForDecompilationModulePass deletes all the bodies of the
  functions that are not isolated functions generated by revng

These passes are used at the beginning of the decompilation pipeline, to
prevent all the passes of the decompilation pipeline to run on root and
other big functions coming from QEMU that do not need to be decompiled.
2020-12-16 18:20:58 +01:00
Pietro Fezzardi 14925de090 libDecompiler: link missing libclangSerialization 2020-12-01 18:03:55 +01:00
Pietro Fezzardi 08c76374a2 MakeEnvNullPass is now a FunctionPass
This fixes an issue causing crashes when calling the public API
`decompileFunction`, that was internally adding a `MakeEnvNullPass`
(formerly a `ModulePass`) to a `FunctionPassManager.
2020-12-01 17:34:30 +01:00