Commit Graph

1218 Commits

Author SHA1 Message Date
Alessandro Di Federico cdf6d5747b tmp 2021-12-14 12:00:36 +01:00
Antonio Frighetto e1528ca13c Drop StackAnalysis 2021-12-14 11:00:00 +01:00
Antonio Frighetto 0e3e8fd060 Artifacts for StackAnalysis2 2021-12-14 11:00:00 +01:00
Antonio Frighetto b9ff97f845 StackAnalysis2: build prototype and finalize model 2021-12-14 11:00:00 +01:00
Antonio Frighetto 16afbd9fab StackAnalysis2: propagate interprocedural results 2021-12-14 11:00:00 +01:00
Antonio Frighetto e892c15cc8 Integrate StackAnalysis2 with ABIAnalyses2
Integrate results of ABIAnalyses2 in StackAnalysis2
and refine such results by suppressing stack pointer
and callee-saved registers from the analyses.
2021-12-14 11:00:00 +01:00
Qian Matteo Chen 12c3ce2dba Introduce ABIAnalyses2
Architecture-agnostic and ABI-independent data-flow analyses that
traverse the recovered functions in order to detect arguments and
return values registers.
2021-12-14 10:59:56 +01:00
Antonio Frighetto 835089705e Introduce StackAnalysis2
An architecture-agnostic analysis that attempts to detect
boundaries of functions, recover the control-flow graph as
well as function prototypes (arguments and return values)
of the original program. The analysis identifies whether
the function jumps to its return address (namely, it is a
regular function), it tracks the evolution of the stack
by determining its height (in order to say if the stack is
left in a correct position upon stackframe destruction),
and it identifies callee-saved registers.
2021-12-10 12:30:11 +01:00
Antonio Frighetto a991ef2406 Introduce AAWriterPass
A simple pass that adds aliasing scope information as
comments to the IR before load and store accesses.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 6328121d02 Introduce IndirectBranchInfoPrinterPass
A simple pass that serializes the results of the StackAnalysis on disk.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 2d46979813 Introduce SegregateDirectStackAccessesPass
A pass which segregates direct stack accesses from all other
memory accesses through appropriate alias information metadata.
By doing so, we provide a way to say that stack accesses reasonably
do not interfere with any other memory access. This pass also tries
to canonicalize `inttoptr` + `add` instructions into `getelementptr`s
so as to avoid the use of `inttoptr`, which would otherwise inhibit
compiler optimizations.
2021-12-10 12:30:11 +01:00
Antonio Frighetto ebf6ab0be9 Introduce CSVAliasAnalysisPass
A pass that decorates memory accesses with
information about CSV aliasing.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 4d716a0b4f Introduce PromoteGlobalToLocalPass
A simple pass that promotes the CSVs to local variables.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 62ca93cd08 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-12-10 12:30:11 +01:00
Antonio Frighetto b5ba55e610 Introduce RemoveNewPCCallsPass
A simple pass that removes the calls to `newpc` marker.
2021-12-10 12:30:11 +01:00
Antonio Frighetto c9f273a93e Improve MFP 2021-12-10 12:30:11 +01:00
Antonio Frighetto bdf27e929d ProgramCounterHandler: emit branches separately
When generating a conditional branch with fallthrough and `anyPC`
basic block, make sure branches are emitted in distinct blocks.
2021-12-10 12:30:11 +01:00
Antonio Frighetto ab597dc52f ProgramCounterHandler: add dissectJumpablePC
The new method `dissectJumpablePC` provides information about the
PC CSVs and allows not to make architecture-specific assumptions.
2021-12-10 12:30:11 +01:00
Antonio Frighetto ec629a20b1 JumpTargetManager: move getOption in IRHelpers 2021-12-10 12:30:11 +01:00
Antonio Frighetto 780a771064 IRHelpers: ignore abort in getFunctionCall 2021-12-10 12:30:11 +01:00
Antonio Frighetto a9315736e1 IRHelpers: refactor getPC
Dead code removal and various fixes while refactoring `getPC`.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 369a0700ac IRHelpers: overload isCallTo and getCallTo 2021-12-10 12:30:11 +01:00
Antonio Frighetto 5b47367395 PromoteCSVs: no wrapper for Marker and Exceptional 2021-12-10 12:30:11 +01:00
Antonio Frighetto 81dd2e5cf3 GeneratedCodeBasicInfo: add purgeDomTree method
Erase element from the DominatorTree map when needed.
2021-12-10 12:30:11 +01:00
Antonio Frighetto a7d26f0148 GeneratedCodeBasicInfo: add invalidate method 2021-12-10 12:30:11 +01:00
Antonio Frighetto 9595894bcf BinaryFile: add architecture-dependent fields
Add return address register and minimal final stack offset in Arch.
2021-12-10 12:30:11 +01:00
Antonio Frighetto 2656b72eed IRHelpers: overload extract for int64_t 2021-12-10 12:30:11 +01:00
Antonio Frighetto bfb2087d43 ZipMapIterator: add support for llvm::DenseMap 2021-12-10 12:30:11 +01:00
Antonio Frighetto 7d50c06123 DwarfImporter: exclude empty names 2021-12-10 12:30:11 +01:00
Antonio Frighetto 61bc764596 CodeGenerator: record static functions as well 2021-12-10 12:30:11 +01:00
Antonio Frighetto c9a42cec36 Model: handle NoReturn functions in CallEdge 2021-12-10 12:30:11 +01:00
Antonio Frighetto 8f563a625c FunctionIsolation: fix object passed by copy 2021-12-10 12:30:11 +01:00
Alessandro Di Federico 0b3aa92bbb FunctionIsolation: handle NoReturn attribute 2021-12-10 12:30:11 +01:00
Alessandro Di Federico f789a3ec5f Introduce model::FunctionAttributes 2021-12-10 12:30:11 +01:00
Alessandro Di Federico 8bb4998b47 Move GCBI.getMetaAddressMetadata to IRHelpers.h 2021-12-10 12:30:11 +01:00
Alessandro Di Federico b9726330f6 Improve scripts/compare-yaml
* Rename from compare-json.py to compare-yaml
* Handle YAML
* Support certain characteristics of the model
* Use subgraph matching to perform comparisons
* Introduce some testing
* Drop Python 2 support
* Reformat
2021-12-10 12:30:11 +01:00
Alessandro Di Federico f9ae47e4d9 Do not by pass HARD flags 2021-12-10 12:30:09 +01:00
Alvise de Faveri 2f4b716e6b Add Model::toString() and writeToFile()
These functions can be used in conjunction to dump the Model on a
file during a gdb session, for example:

```
(gdb)  p  writeToFile(Model->toString(), "/tmp/model.yaml")
```
2021-11-19 10:17:09 +01:00
Alvise de Faveri 267410ac43 Add Attribute::WillReturn to ReadOnly funcs
Without this attribute, newer versions of llvm are not able to
remove calls to `ReadOnly` functions whose return value is unused.

This is instead the expected behavior for the functions that are
generated by `revng` with the `ReadOnly` attribute.
2021-11-19 10:17:02 +01:00
Alessandro Di Federico d3cee7611d revng-dump-model: consider generic MetaAddress too 2021-11-19 10:12:23 +01:00
Alessandro Di Federico 54573608fe revng-dump-model: consume all the input 2021-11-19 10:12:23 +01:00
Alessandro Di Federico e1dadae08d revng-dump-model: ignore YAML tags 2021-11-19 10:12:23 +01:00
Antonio Frighetto adcda3532b AVI: fix error in detection of stores to PC 2021-11-18 15:30:07 +01:00
Alessandro Di Federico 9b61ad1772 scripts/revng: fix typo in ASan handling 2021-11-08 16:18:27 +01:00
Ivan Krysak 52f7432f1b Add model::Architecture::getPointerSize() 2021-11-08 16:17:47 +01:00
Alvise de Faveri 2e19fade43 Fix memory leak in TupleTreeKeyWrapper::clone
ConcreteTupleTreeKeyWrapper::clone() should cleanup the Target object
befor cloning, otherwise the destructor of the inner Pointer object
is never called.
2021-10-27 08:42:53 +02:00
Alessandro Di Federico 0b7787967d Merge branch 'feature/dynamic-functions' 2021-10-21 15:55:44 +02:00
Alessandro Di Federico 93b93a3908 scripts/revng: fix computation of libs dependencies 2021-10-21 15:02:01 +02:00
Pietro Fezzardi c050dcb621 Handle missing model in SerializeModelPass
Before this commit, SerializeModelPass and SerializeModelWrapperPass had
hard dependencies on the passes that load the model from LLVM-IR.

This commit makes this dependency optional. When the passes for model
serialization are executed, if they see that nobody requested to load
the model, they will not try to serialize it.

This prevents them from crashing when running in pipelines that only
contain passes that ignore the model.

This is particularly beneficial because `revng opt` automatically adds
`-serialize-model` at the end of each pipeline and, before this commit,
this meant that `revng opt` could not be used for unit-testing simple
llvm passes that do not use the model.

With this commit, `revng opt` can be used for unit-tests, even on LLVM IR
with missing model.
2021-10-21 15:02:01 +02:00
Andrea Gussoni cd9e4b5df1 check-revng-conventions: improve c files exclusion 2021-10-21 15:02:01 +02:00