Commit Graph

264 Commits

Author SHA1 Message Date
Qian Matteo Chen ff173aea81 [WIP][NewMFPABI] Use enums from the model 2021-06-08 15:01:02 +02:00
Qian Matteo Chen 8e8f52fcb4 [WIP][NewMFPABI] Add RAOFC 2021-06-08 15:01:02 +02:00
Qian Matteo Chen 4e2eec0380 [NewMFP] Forward the GraphType to RPOTE
RPOTE let's us specify the specific GraphTraits needed
This commits adds a template parameter LGT that specifies
the GraphTraits of the Label (the nodes of our flow graph).

This LGT can be distict from GraphType because,
while most of the llvm graphs are structured so that
nodes of a graph are subgraphs of the same type as
the parent graph, it is not true sometimes
2021-06-08 15:01:02 +02:00
Qian Matteo Chen 51928c0fe9 [WIP][NewMFPABI] Add URAOF 2021-06-08 15:01:02 +02:00
Qian Matteo Chen 7352069d56 [WIP][NewMFPABI] Add URVOFC 2021-06-08 15:01:02 +02:00
Qian Matteo Chen aa95ee605f [WIP][NewMFPABI] Add DRAOF 2021-06-08 15:01:02 +02:00
Qian Matteo Chen eac9bb89d0 [WIP][NewMFPABI] Fix non up to date LatticeElement 2021-06-08 15:01:02 +02:00
Qian Matteo Chen b678d82f8a [WIP][NewMFPABI] Exctract common code for analyses 2021-06-08 15:01:02 +02:00
Qian Matteo Chen 9c6af2d528 [WIP][NewMFPABI] Add pass to print analyses result 2021-06-08 15:01:02 +02:00
Qian Matteo Chen c049a4737b [WIP]{NewMFPABI] Fix support for TheCall 2021-06-08 15:01:02 +02:00
Qian Matteo Chen 2ae706b258 [WIP][NewMFPABI] Let user specify the entry nodes 2021-06-08 15:01:02 +02:00
Qian Matteo Chen f4e206f58f [WIP][NewMFPABI] Add first version of DRVOFC 2021-06-08 15:01:02 +02:00
Qian Matteo Chen d6c0e92fd1 [WIP][NewMFPABI] Experiment with DeadReturnValuesOfFunctionCall 2021-06-08 15:01:02 +02:00
Qian Matteo Chen f95fdbced5 [NewMFP] Change MFP to take an instance of MFI
Using static methods for combineValues, isLessOrEqual
and applyTransferFunction prevents us to make analysis
that depend on contextual data.

Supplying a const MFI instance allows us to use do that
2021-06-08 15:01:02 +02:00
Qian Matteo Chen 64657642e7 [NewMFP] Move monotone framework implementation
This commit moves the implementation of the monotone framework
from TypeShrinking to MFP
2021-06-08 15:01:02 +02:00
Antonio Frighetto a487133f56 Introduce StackAnalysis2 2021-05-26 18:08:45 +02:00
Antonio Frighetto 5e664186f0 Introduce IndirectBranchInfoPrinterPass
A simple pass that serializes the results of the StackAnalysis on disk.
2021-05-26 18:07:12 +02:00
Antonio Frighetto cf79b2d6e3 Introduce CSVAliasAnalysisPass
This new pass:
- Adds CSV alias information (previously done by `JTM::aliasAnalysis`)
- Optionally segregates the direct stack accesses from all the other
  memory accesses by adding further alias information
- Canonicalizes the inttoptr + add + ptrtoint into a getelementptr, in
  order to have typesafe pointer arithmetics and allow optimizations
  to happen.
2021-05-26 18:07:04 +02:00
Antonio Frighetto 1caf2f6f6d Introduce PromoteGlobalToLocalPass
A simple pass that promotes the CSVs to local variables.
2021-05-15 15:35:46 +02:00
Antonio Frighetto b72ae42c3a Introduce RemoveHelperCallsPass
A simple pass that removes the calls to the helpers and replaces them
with stores of an opaque value onto the CSVs clobbered by the helper.
2021-05-15 15:35:46 +02:00
Antonio Frighetto f78529330f Introduce RemoveNewPCCallsPass
A simple pass that removes the calls to newpc.
2021-05-15 15:35:46 +02:00
Antonio Frighetto ad4586f401 ProgramCounterHandler: add dissectJumpablePC
The new method `dissectJumpablePC` provides information about the
PC CSVs and allows not to make architecture-specific assumptions.
2021-05-15 15:35:46 +02:00
Antonio Frighetto 5ecb3ef752 IRHelpers: refactor getPC
Dead code removal and various cleanup while refactoring `getPC`.
2021-05-15 15:35:46 +02:00
Alessandro Di Federico 5878fee3e2 Make PCH::addCaseToDispatcher more efficient
Checking if a `SwitchInst` has a certain case triggers a linear search.
When we have *a lot* of jump targets this is an issue.

This commit assumes that when we add a case to a dispatcher, that case
is not already there.
2021-05-12 18:42:13 +02:00
Alessandro Di Federico 10eb8e498a AVI: handle Undef
Also, be more verbose on an unexpected instruction.
2021-05-12 18:31:23 +02:00
Alessandro Di Federico cfddcceb3e IRHelpers: non-const getModule(...) 2021-05-08 19:27:57 +02:00
Alessandro Di Federico 82260c2693 Make dumping assembly and PTC optional
Output files can become *very* large.

This commit disables by default dumping disassembled instructions and
PTC code into the IR.
2021-05-08 19:27:57 +02:00
Alessandro Di Federico 91991bb694 Handle PHIs in lifted code
In large binaries PHI nodes show up. As a consequence, calls to `newpc`
are no longer the first instruction.

This commit uses the `getFirstNonPHI` method to fix this issue.
2021-05-08 19:19:41 +02:00
Alessandro Di Federico 1ac2884f2e Handle blocks ending with unreachable
Sometimes basic blocks end with an
2021-05-08 11:39:10 +02:00
Alessandro Di Federico 871931b9cd Test TupleTreeDiff on Model
`TupleTreeDiff` was not being tested.

This commit implements several `operator==` that are required to
successfully instantiate `TupleTreeDiff`.
2021-05-06 15:42:16 +02:00
Alessandro Di Federico e62f888381 Drop KeyTraits
This commit drops the KeyTraits in favor of a std::any-like solution.
Basically, we type erase any key the user wants to employ, just exposing
a virtual version of the destructor, a comparison operator and a clone
primitive.
2021-05-06 15:42:00 +02:00
Pietro Fezzardi b58693b8e8 RecursiveCoroutine: enable direct continuation
Before this commit, the execution logic of RecursiveCoroutine used an
underlying std::stack allocated on the heap to hold all the
coroutine_handles. It also manually managed passing return values from
callees to callers.

This commit drops this unnecessary auxiliary stack.
When a RecursiveCoroutine co_awaits another one, the handle of the
awaiter is injected into the awaitee, so that when the awaitee is done
it can directly execute the remaining part of the awaiter as a
continuation.
2021-05-05 17:48:04 +02:00
Alessandro Di Federico 7e637beef3 Import static TupleTree validation routines 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 9650369fa7 Import TupleTree and TupleTreeReference 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 0d77258109 Introduce HasKeyObjectTraits concept 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 508bc4eb00 Minor changes 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 6fd8a87572 TupleTree, visit: rename and make more usable 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 51682eb024 model::FunctionEdge: carve out CallEdge 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 582dee6fcc TupleTree: support UpcastablePointer 2021-05-05 17:10:12 +02:00
Alessandro Di Federico 702f4230ac Import UpcastablePointer 2021-05-05 17:10:12 +02:00
Alessandro Di Federico a6468d8d22 Minor changes 2021-05-05 17:10:12 +02:00
Pietro Fezzardi 50681284c0 Conceptify revng
Use concepts across revng wherever possible, to keep the code concise
and easier to understand.
2021-05-05 17:10:12 +02:00
Alessandro Di Federico 0c671ea7ae Introduce RemoveExceptionalCalls
RemoveExceptionalCalls is a simple pass whose goal is to drop all the
calls to functions marked as `Exceptional` and replace them with an
`UnrechableInst`.

This is mainly useful in the decompilation pipeline.
2021-04-30 14:52:25 +02:00
Alessandro Di Federico ce87c30490 Introduce InlineHelpers
InlineHelpers is a simple pass that recursively inlines all the
functions belonging to the section `revng_inline` in isolated functions.
2021-04-30 14:52:25 +02:00
Alessandro Di Federico 53f6328507 Introduce PromoteCSVs
This commit takes out of EnforceABI the part taking care of creating
wrappers for calls to helpers and promoting CSV to local variables.
This decoupling, enables to run -promote-csvs multiple times, for
instance after inlining.
2021-04-22 18:07:24 +02:00
Alessandro Di Federico 2e9c2ee275 Introduce FunctionTags
FunctionTags goal is to solve the long-standing problem of identifying
what type of function are we dealing with. Is it a lifted function? An
helper?

Now we have a sane way to determine this using Metadata and a proper
API.
2021-04-22 18:07:24 +02:00
Alessandro Di Federico 2ea5723a53 s/getCalledValue/getCalledOperand/g 2021-04-22 18:06:27 +02:00
Alessandro Di Federico aeb81c4218 Don't implicitly use StringRef as std::string 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 1e8c43b1d5 PCH::store: pass IRBuilder by reference 2021-04-22 18:06:27 +02:00
Alessandro Di Federico 33fbcd7ac2 AVI: stop backward exploration at dispatcher
This commit greatly improves the performance by ensuring that, when
computing the set of nodes we want to consider for AVI, we do not
traverse the dispatcher.

Doing so, means including *a lot* of irrelevant nodes and wasting a lot
of computation, since the CFG usually is not influenced by stuff
happening before an indirect jump.

In at least a situation the speedup is in the order of 20x, however this
depends on the size of the binary, since traversing the dispatcher means
including all the binary in the computations (as opposed to just the set
of blocks involved in the dataflow to compute a certain expression).
2021-04-22 18:05:39 +02:00