Commit Graph

563 Commits

Author SHA1 Message Date
Pietro Fezzardi ff4f91a570 Model/Type.h: explicit constructors from uint64_t 2022-01-05 13:33:52 +01:00
Pietro Fezzardi e37425c686 TupleTreeReference: add getConst() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi 0e1402adfc Fix is_specialization<const X<T>, X>
Before this commit `is_specialization<const X<T>, X>` was not
specialized, so that `const X<T>` did not count as a specialization of
`X`. This resulted in bad selection of template specialization based on
concepts that were using `is_specialization_v`, such as
`IsUpcastablePointer`.

This commit fixes the problem, so that now the concept
`IsUpcastablePointer` is true for `const UpcastablePointer<T>` as well.

This also enabled to remove some workarounds for the `IsMutableSet` and
`IsSortedVector` concepts, and treat them uniformly with other concepts
that were using `is_specialization_v`.
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 275959618f TupleTree: make Root a std::variant<T *, const T*>
This enables holding TupleTreeReferences to immutable model objects
2022-01-05 13:33:52 +01:00
Pietro Fezzardi 69715dafed TupleTreePath: add empty() method 2022-01-05 13:33:52 +01:00
Pietro Fezzardi c338e79de7 Extend TupleTreeCompatible concept
Before this commit, it was only matched by types that satisfied the
constraint `IsUpcastablePointer`, which is too strict.
Now also types that match `UpcastablePointerLike` satisfy the
constraints for this concept.
2022-01-05 13:33:40 +01:00
Alessandro Di Federico 8c0b918ace s/DebugHelper.*/IRAnnotators.*/ 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 88dbc39f29 Reorganize LLVM IR debug annotations emission 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 6073133545 CodeGenerator: drop IR emission duties 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 4d7a175996 Extract TupleTree 2021-12-22 17:47:54 +01:00
Alessandro Di Federico 777adcbd45 model::Binary: add segments and imported libraries
Now, `scripts/revng` uses the model and we no longer need to emit
.li.csv and .need.csv.
2021-12-22 17:47:54 +01:00
Alessandro Di Federico 5a28bfedea Move SegmentInfo::generateName to BinaryFile.cpp 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 455bf10648 Specialize KeyedObjectTraits for std::string 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 57ae7613e1 Drop obsolete debug files
This commit drops the generation of `.coverage.csv` and `.bbsummary.csv`
files. No one really uses them anymore.
2021-12-22 13:47:21 +01:00
Massimo Fioravanti 9e477d0ada Make a library out of revng-lift 2021-12-22 13:47:21 +01:00
Alessandro Di Federico 7c050ee377 mv include/revng/{TypeShrinking,MFP}/SetLattices.h 2021-12-17 18:51:06 +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 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 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
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 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 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 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
Antonio Frighetto 4eb0f3c29a IRHelpers: overload extract for int64_t 2021-12-15 18:03:30 +01:00
Antonio Frighetto b80be110ae ZipMapIterator: add support for llvm::DenseMap 2021-12-15 18:03:30 +01:00
Antonio Frighetto f1ac5e4075 Model: handle NoReturn functions in CallEdge 2021-12-15 18:03:30 +01:00
Alessandro Di Federico 96d133d72f Introduce model::FunctionAttributes 2021-12-15 18:03:30 +01:00