Commit Graph

232 Commits

Author SHA1 Message Date
Alessandro Di Federico c02df6ea98 Import static TupleTree validation routines 2021-05-03 16:59:05 +02:00
Alessandro Di Federico fc64ccc627 Import TupleTree and TupleTreeReference 2021-05-03 16:59:05 +02:00
Alessandro Di Federico 21986b137f Introduce HasKeyObjectTraits concept 2021-05-03 16:58:21 +02:00
Alessandro Di Federico 54002b937f Minor changes 2021-04-30 15:08:47 +02:00
Alessandro Di Federico 87e752044f TupleTree, visit: rename and make more usable 2021-04-30 15:08:29 +02:00
Alessandro Di Federico d46c397e5d model::FunctionEdge: carve out CallEdge 2021-04-30 14:52:25 +02:00
Alessandro Di Federico bb7485beaf TupleTree: support UpcastablePointer 2021-04-30 14:52:25 +02:00
Alessandro Di Federico 2fb68ca054 Import UpcastablePointer 2021-04-30 14:52:25 +02:00
Alessandro Di Federico 42aa3231ae Minor changes 2021-04-30 14:52:25 +02:00
Pietro Fezzardi 0b24d5d7e3 Conceptify revng
Use concepts across revng wherever possible, to keep the code concise
and easier to understand.
2021-04-30 14:52:25 +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
Alessandro Di Federico 84a4aef1ee nodesBetween: introduce ignore list 2021-04-22 18:05:39 +02:00
Alessandro Di Federico 618dbf3673 s/CSVsUsedByHelperCall/CSVsUsage/g 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 8c27f2bfcd OpaqueFunctionsPool: enumeration and registration 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 694b76a8e2 GenericGraph: propagate graph properties to nodes 2021-04-22 18:03:53 +02:00
Alessandro Di Federico e3157ffdd4 GenericGraph: initialize EntryNode 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 2a93ef2257 IRHelpers: introduce callers() 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 4f7be5a966 IRHelpers: generalize getContext to GlobalObjects 2021-04-22 18:03:53 +02:00
Alessandro Di Federico 2b9cbb98ec Introduce --invoke-isolated-functions
This commit ensures that FunctionIsolation and EnforceABI do only
thing. This means that they no longer modify `root`.

Instead, we have a new pass, `invoke-isolated-functions` that needs to
be run after them and replaces the entry point of the functions with
invokes to the isolated functions, possibly with the appropriate
arguments.
2021-04-22 14:45:52 +02:00
Alessandro Di Federico b25c43705c SerializeModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico c2d6631216 LoadModelPass: support new pass manager 2021-03-16 11:55:58 +01:00
Alessandro Di Federico 035b75d540 TypeShrinking: do not expose dependency on MFP.h 2021-03-08 10:15:50 +01:00
Alessandro Di Federico 23470dc911 Convert TypeShrinking to new pass manager 2021-03-08 10:15:50 +01:00
Alessandro Di Federico 8f05cbf1ee Convert BitLiveness to the new pass manager 2021-03-08 10:15:50 +01:00
Alessandro Di Federico 8a5cc6a020 Import TypeShrinking 2021-03-08 10:15:50 +01:00
Alessandro Di Federico 4780457c53 Drop StackAnalysis<false> and FBDP
This commit drops support for running StackAnalysis without ABI
analysis. This has been broken for quite some time and a source of slow
downs in (badly) crafted optimization pipelines.
2021-03-06 17:35:30 +01:00
Alessandro Di Federico 1db6e5db5b MetaAddress: handle invalid values in operator+= 2021-03-06 16:59:38 +01:00
Alessandro Di Federico 1033c15b78 ABIDetectionPass and FBDP: depend on GCBI
This commit fixes a subtle bug due to `ABIDetectionPass` and
`FunctionBoundariesDetectionPass` using methods from
`GeneratedCodeBasicInfo` (through `StackAnalysis::serializeMetadata`)
without explicitly depending on it.
2021-03-06 16:57:45 +01:00
Alessandro Di Federico 47e34bf897 Make MutableSet copiable
We were using a `std::map<const key_t, value_t>` as internal storage,
which was not copiable. This commit drops the `const`.
2021-03-06 16:56:25 +01:00
Alessandro Di Federico 27b58695a1 Let FunctionIsolation and EnforceABI use the Model 2021-02-19 09:39:49 +01:00
Alessandro Di Federico 0f7de0c2e0 Call to noreturn functions are not killer
We used to mark call to noreturn functions as killers, but this is not
correct.

Note that this is a temporary solution, we need to explicitly handle
such situations.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico b5065e1e8d StackAnalysis: expose FakeReturns 2021-02-19 09:39:49 +01:00
Alessandro Di Federico f2c83d2f67 Introduce PlainMetaAddress
This commit extracts a plain `struct` from the `MetaAddress` class. This
enables us to use `MetaAddress` from C and therefore, runtime.

The definition of such `struct`, `PlainMetaAddress`, is in
`PlainMetaAddress.h`, which is included by `early-linked.c`.

A function to print the content of a `PlainMetaAddress` has also been
introduced.

Also, anticipating the linkage of `early-linked.c` triggered a
superflous assertion in `CPUStateAccessAnalysis`. This commit removes
it.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico df11232fe1 Improve GCBI
* Introduce GCBI::buildDispatcher
* Introduce GCBI::getJumpTarget{,Block} and GCBI::getBlocksGeneratedByPC
  to easily map `BasicBlock *` to jump targets and viceversa.
* PCH::buildDispatcher now returns a list of the newly created basic
  blocks.
* Other minor changes
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 93b7420c8a Implement model::Function::dumpCFG 2021-02-19 09:39:49 +01:00
Alessandro Di Federico 82605514c4 model: prepare for ABI information
This commit also drops some dead code and fixes Model tests accordingly.
2021-02-19 09:39:49 +01:00
Alessandro Di Federico 6cfcd087b7 Introduce ProgramCounterHandler::loadPC 2021-02-18 19:13:06 +01:00
Alessandro Di Federico 8952ca3cc1 IRHelpers.h: introduce createFunctionType 2021-02-18 18:46:49 +01:00
Alessandro Di Federico 575a0d6a6d IRHelpers.h: introduce isHelper 2021-02-18 18:46:49 +01:00
Alessandro Di Federico 0ebb32f25e GCBI: make certain methods static 2021-02-18 18:46:49 +01:00
Alessandro Di Federico ee9f2192f3 KOC::batch_insert: return newly created object 2021-02-18 18:46:49 +01:00
Alessandro Di Federico e9ca81247d Improve get*FromYAML*
This commit fixes the following issues:

1. It introduces `getNameFromYAMLEnumScalar` which returns a
   `llvm::StringRef` instead of a `std::string`.
2. Lets users decide what to do when `getValueFromYAMLScalar` does not
   get any match (abort by defaul, or return an "Invalid" value).
2021-02-18 18:44:42 +01:00
Alessandro Di Federico a96c6d4931 get{Name,Value}FromYAMLScalar: support quotes 2021-02-18 18:44:42 +01:00