Commit Graph

6113 Commits

Author SHA1 Message Date
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 8ab26f8d7f Adopt TupleTreeReference::empty() 2023-10-05 10:19:44 +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 d8147aa62e Introduce TupleTreeReference::dump 2023-10-05 10:19:44 +02:00
Alessandro Di Federico c6425b2618 TupleTree::verify: more fine grained assertions 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 456b916bcc Move TypePath definition 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
Pietro Fezzardi 0e576544b1 Merge branch 'feature/llvmir-prepare-for-mlir' 2023-10-03 10:20:38 +02:00
Pietro Fezzardi e2dc45c31a Merge branch 'feature/llvmir-prepare-for-mlir' 2023-10-03 10:18:17 +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 c5f9a61037 Remove make-segment-ref from segregate.yml
We remove this since that was ignored by the parser and didn't
have any effect.
2023-09-21 08:44:47 +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
Alessandro Di Federico f95ef2bda7 Merge branch 'feature/dormitory' 2023-09-14 15:44:36 +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 6b6bfd2693 pipeline::Option: fix TypeName
Fix the `getTypeName` function needed to report the type of an Analysis'
option.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi 29b229455f Tuple Tree: rename Parent in struct.h.tpl
Rename the Parent attribute of a struct to BaseClass to avoid conflicts
with Tuple Tree structs that might need that attribute.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi 786d01925a tuple_tree_gen.ts.tpl: fix Global name alias
Fix the case in the typescript tuple tree generator where the global
name coincides with the name of the root object.
2023-09-14 15:44:32 +02:00
Giacomo Vercesi 90ea42b695 model/_util.py: move into tupletree.py
Move the contents of `model/_util.py` into `tupletree.py` as it's
model-agnostic and used by all generated Python tuple-tree wrappers.
2023-09-14 15:44:32 +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