Commit Graph

3168 Commits

Author SHA1 Message Date
Alessandro Di Federico a11435becf BinaryImporter: error on unsupported formats 2023-10-06 17:16:04 +02:00
Alessandro Di Federico c9b95c0556 DetectABI::propagatePrototypes: improve logging 2023-10-06 17:16:04 +02:00
Alessandro Di Federico 4fe4d05895 CCodeGenerator::ParentPrototype: drop Parent 2023-10-06 17:14:29 +02:00
Alessandro Di Federico 2a7e06df1f printFunctionPrototype: add newline after ABI
This commit forces getLocationAttribute's argument to be false.
2023-10-06 17:14:29 +02:00
Alessandro Di Federico 6141717440 CCodeGenerator: emit comment after noreturn calls 2023-10-06 17:14:27 +02:00
Alessandro Di Federico 9f3b832009 CCodeGenerator: add space in struct initializers 2023-10-05 19:18:38 +02:00
Alessandro Di Federico cb8aa3d929 Adopt .prototype()
Also adopt `QualifiedType::getFunctionType` where appropriate in order
to unwrap typedefs.
2023-10-05 19:18:38 +02:00
Alessandro Di Federico cae213b36b Minor changes 2023-10-05 18:45:17 +02:00
Alessandro Di Federico 3f13fd0c08 PTML Doxygen: emit comment only if present 2023-10-05 10:19:44 +02:00
Alessandro Di Federico aa878e2d12 DetectABI::finalizeModel: delay CFG verification
This ensures all changes have applied and things are coherent.
2023-10-05 10:19:44 +02:00
Alessandro Di Federico 7dff660b36 propagatePrototypesInFunction: propagate names 2023-10-05 10:19:44 +02:00
Alessandro Di Federico e919fff6e7 DetectABI: posticipate propagatePrototypes
This change avoids making changes to the model that `finalizeModel` does
not expect.
2023-10-05 10:19:44 +02:00
Alessandro Di Federico 52dc3faf2c CFGAnalyzer: noreturn tail calls do not return 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 2cbf3a8313 TypeCopier: minor rework 2023-10-05 10:19:44 +02:00
Alessandro Di Federico bf66ecc389 {,Dynamic}Function::Prototype: support typedefs 2023-10-05 10:19:44 +02:00
Alessandro Di Federico 7ba01f513b ABIAnalyses: fix collection points
The collection points of several ABI analyses where incorrect. Several
analyses that should have collected data only from entry points were
collecting data from any node in the graph.
2023-10-04 17:47:50 +02:00
Alessandro Di Federico 676654ea7b ABIAnalysis: improve logging 2023-10-04 17:47:50 +02:00
Alessandro Di Federico 111b3a819d CFGAnalyzer::milkInfo: add logging 2023-10-04 17:47:50 +02:00
Alessandro Di Federico b67e2ac13a Minor changes 2023-10-04 17:47:50 +02:00
Djordje Todorovic 68400d9b30 Import from LLVM IR to MLIR
- Add PrepareLLVMIRForMLIR Pass.
  This Pass performs massaging of the LLVM IR
  produced by revng so it can be parsed/accepted
  for the LLVM MLIR Dialect.
- Introduce new pipeline branch: llvmir-to-mlir.yml.
- Add LLVMIRToMLIR step.
- Add ImportLLVMToMLIRPipe pipe.
2023-10-02 17:13:55 +02:00
Pietro Fezzardi 08939f2ae8 OpaqueExtractValues: set name for struct type
This commit sets a name for types we use in OpaqueExtractValues.
These are StructTypes that can only be returned from isolated functions
with RawFunctionType prototype on the model, or from helpers that do not
represent isolated functions.

The name is required because when we will converto to MLIR LLVM Dialect,
there are checks in place that forbid unnamed types.
The code re-uses code that is used to print C code, in order to make
sure that the struct names we use for this are the same as those we emit
in C, to ease debugging.

This commit also cleans up the unittest to make it more concise, while
still testing the same things.
2023-10-02 17:13:55 +02:00
Pietro Fezzardi 8df32f84cc BeautifyGHAST: drop broken code in hasSideEffects
This commit drops some old broken code that was a leftover from when
MarkAssignments didn't inject calls to Assign, and that was poorly
migrated to Assign, causing it to be dead code.
2023-10-02 17:10:15 +02:00
Pietro Fezzardi bd832cb140 MarkAssignments: use model types for LocalVariable
Before this commit all the local variabels emitted by MarkAssignments
were using integer types obtained with llvmIntToModelType.

This commit enables using model::QualifiedTypes more often, resulting in
overall more readable C code.
2023-10-02 17:10:14 +02:00
Pietro Fezzardi f72215485d ExitSSA: ignore undef incoming values of PHI 2023-09-27 16:48:22 +02:00
Pietro Fezzardi dd76d3bef9 BeautifyGHAST: fix hasSideEffects for NotNode
This commit fixes a bug in the hasSideEffects function, used to evaluate
if an ExprNode has side effects.
Before this commit, when calling hasSideEffects on a NotNode, the
return value was true if the operand of NotNode **did not** have side
effects, which is wrong.
This commit changes the behaviour so that a NotNode has side effects if
and only if its only operand has side effects.
2023-09-27 16:48:22 +02:00
Pietro Fezzardi 398f0888d0 BeautifyGHAST: fix hasSideEffects for AndNode
This commit fixes a bug in the hasSideEffects function, used to evaluate
if an ExprNode has side effects.
Before this commit, when calling hasSideEffects on an AndNode, the
return value was true if **both** the LHS and RHS of the AndNode had
side effects, which is wrong.
This commit changes the behaviour so that if **either** LHS **or** the
RHS of the And have any side effect, than hasSideEffects returns true
for the And.
2023-09-27 16:48:19 +02:00
Pietro Fezzardi ce6935bec7 BeautifyGHAST: simplifyShortCircuit recurs on if
Before this commit, the simplifyShortCircuit beautifier did not recur on
the then/else branch of an IfNode, basically stopping recursion very
early and potentially missing a lot of beautification opportunities.
2023-09-27 16:48:10 +02:00
Pietro Fezzardi 7df0aa0dd5 Add readonly memory effect to OpaqueExtractValue
This enables DCE to remove unused calls to OpaqueExtractValue,
also preventing them to show up in decompiled C code.
2023-09-27 16:48:03 +02:00
Pietro Fezzardi 07cf95159e DLA Frontend: fix handling of pointer-typed SCEVs
Before this commit the DLA frontend was not ready to handle all the
possible combinations of integer- and pointer-typed arithmetic that was
used to compute SCEVs.
This could cause crashes when dealing with pointer-typed SCEVs.
This commit fixes the issues by converting all pointer-typed expressions
to integers, and resizing integers to the same size before adding them.
2023-09-21 15:18:32 +02:00
Pietro Fezzardi ca2f26e40a DLA: don't dump .dot files with VerifyLog 2023-09-21 15:18:23 +02:00
Pietro Fezzardi 8d9f07d7a7 Change indentation of all decompiled C code
This commit changes the indentation of all the C code we emit, from 4
whitespaces to only 2 whitespaces.
2023-09-21 15:17:44 +02:00
Djordje Todorovic ab6bc6473c pipeline: Emit error if a pipe is not LLVM one
A consequence will be that parser will ignore those silently.
2023-09-21 08:05:50 +02:00
Djordje Todorovic fc88a52fae AttachDebugInfo: Fix for MLIR
Up until now, we did not need different !dbg/DISubprogram
attached to each isolated llvm::Function, but for the
purpose of MLIR lowering, we need it.

On the LLVM IR level, we used to reuse root's DISubpgram,
and we have not being attaching !dbg/DISubprogram to the
isolated functions at all (just to llvm::Instructions),
but that was an hack in order to avoid some LLVM verify
checks, since LLVM IR expects !dbg attachments to calls of
functions that could be inlined, but by avoid !dbg on the
Function itself, it won't verify !dbg attachments on the
instructions, since it will assume it has no debug info in
it. When it comes to MLIR, it expects different !dbg
attached to each function, in order to process debug info
in it, so that is the reason we cannot rely on the root
DISubprogram only anymore.
2023-09-21 08:05:49 +02:00
Djordje Todorovic 2760599483 Add StripDebugInfoFromHelpers Pass
During this phase (EnforceABI) the binary is not meant to be run
so the debug info is not useful anymore, so we are striping them
now in order to avoid taking care of them during the pipeline.
2023-09-21 08:05:48 +02:00
Pietro Fezzardi 267e06c052 DLA: add caching to SimplifyInstanceAtOffset0
This commit adds caching for mutual reachability among children of a
node, in SimplifyInstanceAtOffset0.
This makes the DLAStep 10% to 50% faster on real-world benchmarks we
have measured, such as `updatedb.plocate` and `df` for Ubuntu 22.04
x86_64.
2023-09-20 16:36:48 +02:00
Pietro Fezzardi 990f8aab03 Drop unused set from DLATypeSystem.cpp 2023-09-20 16:36:34 +02:00
Pietro Fezzardi 9e36c02442 MarkAssignments: drop unused map 2023-09-20 16:36:28 +02:00
Pietro Fezzardi 01f338be29 Add progress bars to DecompileFunction.cpp 2023-09-20 16:36:21 +02:00
Giacomo Vercesi e2504dd6f2 Implement storage credentials update
Add the functionality to rev.ng's infrastructure to allow to dynamically
update the credentials of the underlying storage provider at runtime.
2023-09-14 17:32:08 +02:00
Giacomo Vercesi 0c5bc8c120 Drop unused functions from PipelineC
Remove all the functions that are no longer needed by `revng.api`.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi f710af9f2f Cleanup revng.daemon graphql API
Drop autogenerated queries from the GraphQL API and switch `revng.api`
to use `PipelineDescriptor`.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi 2a239ddf47 Introduce PipelineDescription
Add the PipelineDescription object that describes the structure of a
pipeline. This will be used by all the downstream users instead of
pipeline accessor methods via PipelineC.
2023-09-14 15:44:33 +02:00
Giacomo Vercesi d2967d2a49 Tuple Tree Generator: remove Model headers
This commit removes the inclusion of the `Binary.h` header in
Tuple-Tree Generator files, allowing Model-independent Tuple Trees to be
generated.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi aa8eb26028 S3StorageClient: fix bug in generateNewFilename
Fix a corner-case where an '/' would be erroneously prepended if the
Path did not contain a directory name.
2023-09-14 15:44:32 +02:00
Pietro Fezzardi c04b96f72a DLA: RemoveBackedges.cpp uses EquivalenceClasses
llvm::EquivalenceClasses is an efficient data structure from LLVM, to
compute equivalence classes among objects with Tarjan's union-find.

This commit uses that to avoid an hand-crafted very inefficient
algorithm.
2023-09-07 12:19:35 +02:00
Pietro Fezzardi b8c48be350 Add progress bars to DLA 2023-09-07 12:19:35 +02:00
Giacomo Vercesi 0b2754c824 pipeline: drop Disk from storage methods
This commit changes the following method names across the codebase:
* `storeToDisk` -> `store`
* `loadFromDisk` -> `load`
This has been done since the storage is no longer bound to the local
storage.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi 4a2cd259e3 Introduce GzipTarFile
Add the GzipTarFileWriter and GzipTarReader classes that allow reading a
slightly custom `.tar.gz`.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi 93d3a6238d revng: introduce S3 support
Add the capability for all revng tooling to run with an S3-backed
workdir.
2023-09-06 15:23:43 +02:00
Giacomo Vercesi a84ebd0e51 revng.daemon: trim Eventmanager's functionality
Drop most of the functionality provided by EventManager. Add the
functionality that allows saving the working directory after a period of
inactivity.
2023-09-06 15:23:43 +02:00