22 Commits

Author SHA1 Message Date
Alessandro Di Federico c883bed765 Drop Logger's StaticEnabled feature 2025-10-31 17:25:03 +01:00
Pietro Fezzardi e32e224572 Treat llvm.fshl and llvm.fshr as statements
This forces all such instructions to get their value stored into a local
variable in SwitchToStatements.
The reason for doing this is that they often contribute to the formation
of pathological dataflows, causing exponential path explosion when
expanded into C expressions during decompilation.
Serializing their value into a dedicated local variable breaks such an
exponential path explosion.

This is a temporary workaround, that we've already put in place for
SelectInst too, and that will be replaced in the future by a more
principled approach for splitting pathological dataflows that lead to
exponential path esplosion.
2025-10-24 15:34:12 +02:00
Alessandro Di Federico f8bd4c3bac Move around some files in preparation for libtcg
* Make the following private headers public:
  * Lift/CPUStateAccessAnalysisPass.h
  * Lift/CSVOffsets.h
  * Lift/PTCDump.h
  * Lift/VariableManager.h
* Move from revngSupport to revngLift:
  * IRAnnotators.{h,cpp}
  * SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
  * FunctionTags.{h,cpp}
  * ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
  * OriginalAssemblyAnnotationWriter.{h,cpp}
2025-10-24 15:34:11 +02:00
Ivan Krysak 3561c2b907 Adopt IRBuilder wrapper 2025-10-21 19:17:01 +03:00
Pietro Fezzardi 4e4f194b4a SwitchToStatements: fix noAlias when writeOnly
This commit fixes a bug in the `noAlias` function, that failed to detect
two aliasing accesses when the second was writeOnly (so it did not read
memory).

That causes the transfer function of the Available Expression analysis
in SwitchToStatements to wrongly see some expressions as available,
because of the undetected aliasing write that would otherwise overwrite
the available expression.
2025-10-17 15:00:36 +02:00
Pietro Fezzardi 03e0de9458 Improve debug info propagation in legacy pipeline 2025-09-10 17:44:02 +02:00
Lauri Vasama 4e17287cfc Add LLVM-to-Clift import 2025-07-17 16:45:03 +02:00
Pietro Fezzardi df3b4758e4 Add initModeTypesConsideringUses
Before this commit, initModelTypes always looked at uses of each
instructions to see if its knowledge of the instruction's model type
could be improved.

This is useful in some cases, but it's detrimental when building model
casts, because this requires to see the exact type computed for an
instruction.

This commit introduces a new function initModeTypesConsideringUses,
which works like old initModelTypes, considering uses.
In this way we can make sure that uses are considered when necessary,
like when computing types to build new local variables, and ignored when
necessary, e.g. when building model casts.
2025-05-29 09:38:01 +02:00
Pietro Fezzardi 95d44d254b SwitchToStatement: emit copies on each use
Before this commit, SwitchToStatement, in Legacy mode, was evaluating
the injection of Copy instruction an all uses at the same time, while
it's perfectly feasible, depending on how the surrounding IR is shaped,
that calls to Copy are only necessary on some of the uses.

This commit fixes, that evaluating the emission of a call to Copy on
each Use separately.
2025-03-05 14:47:46 +01:00
Pietro Fezzardi 391f5c780f SwitchToStatements: use LocalVariableBuilder 2025-01-29 23:55:49 +01:00
Pietro Fezzardi e9528f4647 Fix getCopyType function type
This commit changes the prototype of getCopeType, so that it now takes 2
arguments.
1. The llvm::Type returned by the Copy function. This can be any scalar
   llvm::Type.
2. The llvm::type of the argument representing the reference to the
   value being copied. This should be a pointer-sized integer, where
   pointer-sized means with the same size of a pointer in the
   architecture in the input binary.

The second argument is not strictly necessary for now, because the whole
decompilation framework expects a binary with a single architecture,
hence a well defined unambiguous pointer size.
This will be used fully only when we start supporting multiple binaries.
Whenever that happens, if we haven't already fully dropped the Copy
helper function we will have to update the associated
OpaqueFunctionsPool to a type pair as key: the return type and the type
of the argument.
2025-01-29 15:17:15 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico 2e4f4d09b9 Remaining FunctionTags have been moved to revng 2024-11-04 15:09:56 +01:00
Alessandro Di Federico e239e18b0c Adopt FunctionPoolTag 2024-11-04 15:09:56 +01:00
Alessandro Di Federico 8706fd8459 Initialize pointers to nullptr 2024-09-27 10:35:10 +02:00
Alessandro Di Federico 9c99ac33ac s/serializeToLLVMString/toLLVMString/ 2024-09-27 10:35:10 +02:00
Ivan Krysak 94a0ad6b93 Adopt reworked model::Type 2024-06-27 11:07:01 +02:00
Alessandro Di Federico 5186a58053 s/FunctionMetadata/ControlFlowGraph/ 2024-06-18 17:56:24 +02:00
Pietro Fezzardi d102835490 Fix stack aliasing in AvailableExpressionAnalysis
Before this commit, the AvailableExpressionAnalysis used by
SwitchToStatements did not take into account the full set of custom
opcodes that allocate local variables.

In particular, if only checked FunctionTags::LocalVariable, and not the
larger set marked with the tag FunctionTags::AllocatesLocalVariable,
which includes revng_stack_frame and revng_call_stack_arguments.

This caused all the reasoning on aliasing that involved the stack to be
broken.

This commit fixes the problem by properly using the
FunctionTags::AllocatesLocalVariable to reason about aliasing.
2024-05-14 18:20:50 +02:00
Pietro Fezzardi 223fa4a7ed Fix InstructionToSerializePicker on MemoryRead
Before this commit, the InstructionToSerializePicker had a wrong bailout
condition, that caused to never pick for serialization memory reads.

This was wrong and caused semantic bugs, due to the instruction
performing the memory read not being serialized into a new variable.
2024-05-14 18:20:50 +02:00
Pietro Fezzardi 4baff26fca SwitchToStatements: handle self-assignments 2024-03-25 18:08:35 +01:00
Pietro Fezzardi 70c8ae48ff Retire MarkAssignment for SwitchToStatements 2024-03-19 09:44:00 +01:00