Commit Graph

1642 Commits

Author SHA1 Message Date
Alessandro Di Federico 1ad2522240 Minor changes 2021-12-22 13:47:21 +01:00
Alessandro Di Federico a1a145147c Merge branch 'feature/detect-stack-size' 2021-12-22 13:41:39 +01:00
Alessandro Di Federico 65e8923fcc GCBI::getSuccessors: relax assertion 2021-12-22 13:40:47 +01:00
Alessandro Di Federico 7c050ee377 mv include/revng/{TypeShrinking,MFP}/SetLattices.h 2021-12-17 18:51:06 +01:00
Alessandro Di Federico f1ce1f9980 compare-yaml: handle - as stdin 2021-12-17 18:50:57 +01:00
Alessandro Di Federico c64223a80c mv scripts/{,revng-}compare-yaml 2021-12-17 18:50:49 +01:00
Alessandro Di Federico 7cc2e914d7 compare-yaml: switch to grandiso.find_motifs
We need to use the `interestingness` in order to have good performance.
2021-12-17 18:50:41 +01:00
Alessandro Di Federico 101e7f7e09 compare-yaml: add attribute for references 2021-12-17 18:50:33 +01:00
Alessandro Di Federico fd08154452 compare-yaml: support negation 2021-12-17 18:50:25 +01:00
Alessandro Di Federico 786598d633 compare-yaml: ignore classes upon deserialization 2021-12-17 18:50:16 +01:00
Alessandro Di Federico 3e1e69e08f Introduce eraseFromParent 2021-12-17 18:50:08 +01:00
Alessandro Di Federico ddfa9ae767 getPointeeSize: assert bit size is divisible by 8 2021-12-17 18:49:59 +01:00
Alessandro Di Federico 4b6a557a19 Fix key issues in -promote-csv
The following bugs have been fixed:

* PromoteCSV no longer mixes `alloca` with other instructions, which is
  a convention in LLVM IR that some passes rely upon.
* Before this commit, we were detecting if *calls to CSV initializers*
  where already present in order to reuse them, but this was not right,
  we need to reuse the *alloca* instructions they are associated
  with. This commit does exaclty that.
2021-12-17 18:49:51 +01:00
Alessandro Di Federico a2364bc6a0 GeneratedCodeBasicInfo: parse root lazily
This commit makes sure that GeneratedCodeBasicInfo can be used even in
absence of the `root`.

This also ensure that no time is wasted on brief/focused pipelines that
do not care about analyzing each basic block in the `root` function.
2021-12-17 18:49:42 +01:00
Alessandro Di Federico e113cb579e Introduce revng/Model/IRHelpers.h 2021-12-17 18:49:34 +01:00
Alessandro Di Federico 04633a21ca Tag call sites with CallToLifted 2021-12-17 18:49:26 +01:00
Alessandro Di Federico ec0e88351d model::Function: make CFG the last field 2021-12-17 18:49:17 +01:00
Alessandro Di Federico 9b05bfd2ba StackAnalysis: record FinalStackOffset 2021-12-17 18:49:09 +01:00
Alessandro Di Federico 8ead934c8e 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-17 18:49:01 +01:00
Alessandro Di Federico 09914e56cf model::Type::dump: upcast 2021-12-17 18:48:52 +01:00
Alessandro Di Federico ca899c96f5 Debug output: pad before ] 2021-12-17 18:48:44 +01:00
Alessandro Di Federico 9a60a5fd82 Expand IRHelpers
* New `getCallTo` overloads accepting `Function *`
* `setInsertPointToFirstNonAlloca`
* Various additional helpers for Load/StoreInst
* `changeFunctionType`
2021-12-17 18:48:36 +01:00
Alessandro Di Federico 1dbe474873 Whitespace fixes 2021-12-16 11:56:06 +01:00
Alessandro Di Federico 90d3484841 Merge branch 'feature/stackanalysis' 2021-12-15 18:40:04 +01:00
Antonio Frighetto 10f45c593a Move StackAnalysis to EarlyFunctionAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto ffd5ac7f57 Drop old StackAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto 9767f4975b Artifacts for EarlyFunctionAnalysis 2021-12-15 18:03:30 +01:00
Antonio Frighetto 10704a8981 EFA: build prototype and finalize model 2021-12-15 18:03:30 +01:00
Antonio Frighetto 92591d42c3 EFA: propagate interprocedural results 2021-12-15 18:03:30 +01:00
Antonio Frighetto 35311dcf14 Integrate EarlyFunctionAnalysis with ABIAnalyses
Integrate results of ABIAnalyses in EarlyFunctionAnalysis
and refine such results by suppressing stack pointer
and callee-saved registers from the analyses.
2021-12-15 18:03:30 +01:00
Qian Matteo Chen 886e58553b Introduce new ABIAnalyses
Architecture-agnostic and ABI-independent data-flow analyses that
traverse the recovered functions in order to detect arguments and
return values registers.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 74a35bca10 Introduce new EarlyFunctionAnalysis
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 determines 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-15 18:03:30 +01:00
Antonio Frighetto a574f3c8e3 Introduce AAWriterPass
A simple pass that adds aliasing scope information as
comments to the IR before load and store accesses.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 14f0e9ed09 Introduce IndirectBranchInfoPrinterPass
A simple pass that serializes the results of the StackAnalysis on disk.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 4ed08d1e94 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-15 18:03:30 +01:00
Antonio Frighetto 215dab9dd2 Introduce CSVAliasAnalysisPass
A pass that decorates memory accesses with
information about CSV aliasing.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 9a59cee319 Introduce PromoteGlobalToLocalPass
A simple pass that promotes the CSVs to local variables.
2021-12-15 18:03:30 +01:00
Antonio Frighetto e9439a15e5 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-15 18:03:30 +01:00
Antonio Frighetto ba49937a69 Introduce RemoveNewPCCallsPass
A simple pass that removes the calls to `newpc` marker.
2021-12-15 18:03:30 +01:00
Antonio Frighetto cbd81e57d9 Improve MFP 2021-12-15 18:03:30 +01:00
Antonio Frighetto 976398aeb6 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-15 18:03:30 +01:00
Antonio Frighetto 47fa41d784 ProgramCounterHandler: add dissectJumpablePC
The new method `dissectJumpablePC` provides information about the
PC CSVs and allows not to make architecture-specific assumptions.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 4504b3d770 JumpTargetManager: move getOption in IRHelpers 2021-12-15 18:03:30 +01:00
Antonio Frighetto dc3f73c622 IRHelpers: ignore abort in getFunctionCall 2021-12-15 18:03:30 +01:00
Antonio Frighetto 8328575839 IRHelpers: refactor getPC
Dead code removal and various fixes while refactoring `getPC`.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 4a0dd2d2d6 IRHelpers: overload isCallTo and getCallTo 2021-12-15 18:03:30 +01:00
Antonio Frighetto b5f87748eb PromoteCSVs: no wrapper for Marker and Exceptional 2021-12-15 18:03:30 +01:00
Antonio Frighetto 1d8a3281a8 GeneratedCodeBasicInfo: add purgeDomTree method
Erase element from the DominatorTree map when needed.
2021-12-15 18:03:30 +01:00
Antonio Frighetto 5b4e4d8e84 GeneratedCodeBasicInfo: add invalidate method 2021-12-15 18:03:30 +01:00
Antonio Frighetto 34580789eb BinaryFile: add architecture-dependent fields
Add return address register and minimal final stack offset in Arch.
2021-12-15 18:03:30 +01:00