Commit Graph

154 Commits

Author SHA1 Message Date
Giacomo Vercesi d63bba17c6 Implement LLMRenameAnalysis
Implement an analysis in revng which allows renaming the variables of a
C function via an LLM.
2025-05-06 09:59:46 +02:00
Andrea Gussoni 928edb0015 Pipeline: introduce materializetrivialgoto 2025-04-30 16:10:54 +02:00
Pietro Fezzardi 5ca182578b Add InstCombineNoArraysPass
This pass wraps LLVM's vanilla InstCombine, to hijack one of its
options. The goal of this hijack is to prevent InstCombine from
splitting and replacing accesses to arrays with GEPs and smaller
accesses.
2025-04-22 17:23:37 +02:00
Pietro Fezzardi ef2c3a7626 Add SROANoArraysPass
This pass wraps LLVM's vanilla SROA, to hijack one of its options.
The goal of this hijack is to prevent SROA from splitting and replacing
memory accesses to arrays with GEPs and smaller accesses.
2025-04-22 17:19:56 +02:00
Andrea Gussoni bb4bdec403 Pipeline: introduce dagify and decidewithgotos
The `prepare-for-clift` artifact now encompasses the run of `dagify` and
`decidewithgotos` (`select-scope` + `ids`).
2025-04-02 16:47:14 +02:00
Alessandro Di Federico c5b9728289 LocalVariableBuilder: add pointer size assumption
This commit further centralizes the creation of allocas + ptrtoint.  The
creation of these pair of instructions is problematic when the size of a
pointer in the input and target architecture differ.

In fact, in such cases, LLVM turns trunc into masking the integer to
suppresse the high bits. This results in problematic code.

This commit introduces an assumption that ensures LLVM does not do that.
2025-03-17 08:51:29 +01:00
Ivan Krysak 45e01ae0d2 Introduce a pipe for embedding statement comments 2025-02-13 13:09:50 +02:00
Pietro Fezzardi 5dc4d86f81 Pipeline: squash late-optimize into segregate
Passes without an artifact and a single successor are pointless anyway.
You can't get their output with revng artifact but you need to save
them on disk.
2025-01-29 23:55:49 +01:00
Pietro Fezzardi 1f0c8e1ae5 Pipeline: remove import-clift-types Pipe
At the moment this pipe is broken, because it claims to be producing
artifacts with function rank, while it only produces types.

This pipe should be extended and turned into a pipe that generates
the whole Clift module including functions from LLVM IR, and not just
types.

We should add an input LLVMContainer, and the run() method should first
import types, and then create the functions and their bodies.

For the time being the Pipe is removed from the pipeline.
2025-01-29 23:55:49 +01:00
Pietro Fezzardi 9e0f015eb8 Drop old conversion from LLVM to MLIR
The previous conversion from LLVM to MLIR was translating plain LLVM IR
to LLVM MLIR Dialect, as a preliminary step for further conversion from
LLVM MLIR Dialect to Clift.
This is not how things are expected to work anymore, so the old code is
now dead and can be removed.
2025-01-29 23:55:49 +01:00
Pietro Fezzardi 186798c2aa Add initial part of clift-based decompilation 2025-01-29 23:55:49 +01:00
Pietro Fezzardi 7be6491258 Pipeline: avoid duplicate SingleTargetFilename 2025-01-29 23:55:49 +01:00
Pietro Fezzardi 391f5c780f SwitchToStatements: use LocalVariableBuilder 2025-01-29 23:55:49 +01:00
Pietro Fezzardi 59a1434fab Segregate: add template for legacy local variables
Introduce LegacySegregateStackAccessesPipe

This commit restructures the SegregateStackAccesses pass and
SegregateStackAccessesPipe so that they can have 2 modes of operations:
1. Legacy, with the same behavior as the old version, injecting local
   variables as custom llvm::Functions representing opcodes, such as
   LocalVariable, AddressOf, StackFrameAllocator, and CallStackArguments
   allocator.
2. Non-legacy, that is meant to operate with the new LocalVariableHelper
   to inject local variables as regular alloca instructions, with
   additional metadata to discriminate among them.

This commit renames the old SegregateStackAccessesPipe to
LegacySegregateStackAccessesPipe.
It then re-uses the old SegregateStackAccessesPipe name for a new pipe,
meant to work in non-legacy mode.

The pipeline definition YAML file is updated to keep using the legacy
version for now.

For now the implementation is still the same.
2025-01-29 15:17:15 +01:00
Pietro Fezzardi f4c79e0579 Pipeline: fix typo 2025-01-29 15:17:15 +01:00
Alessandro Di Federico ade0603d3f Add docs for artifacts and analyses 2024-12-11 16:15:10 +01:00
Alessandro Di Federico 143c315196 Merge revng-c into revng 2024-11-21 10:50:55 +01:00
Alessandro Di Federico ba186a130c s/module.ll/module.bc.zstd/g 2024-11-12 14:58:00 +01:00
Alessandro Di Federico 30f464119e s/module.ll/module.bc.zstd/g 2024-11-11 16:51:18 +01:00
Alessandro Di Federico 55fd4d9f66 s/cfg.yml/cfg.yml.tar.gz/ 2024-09-29 12:53:23 +02:00
Alessandro Di Federico c5f2c8055e s/cfg.yml/cfg.yml.tar.gz/ 2024-09-27 20:45:26 +02:00
Alessandro Di Federico e1f46264f8 Ensure every pipe commits what it should 2024-09-26 17:51:07 +02:00
Alessandro Di Federico d28af50f84 DetectStackSize: handle counted loops 2024-08-23 18:01:47 +02:00
Alessandro Di Federico b096da3b4b revng-c-pipelines.yml: add early-type-shrinking 2024-07-10 17:24:56 +02:00
Pietro Fezzardi d72139357f Add DecompileToDirectoryPipe
This pipe decompiles all the C code in a single directory, packaged up
as a .tar.gz file.
2024-06-27 17:26:18 -04:00
Pietro Fezzardi a12b621832 Add CleanupIRPass 2024-06-27 17:14:28 -04:00
Ivan Krysak 74f56bcd93 Introduce a broken debug info removal pass 2024-06-27 11:07:02 +02:00
Ivan Krysak dfa7478685 Adopt reworked model::Type 2024-06-27 11:05:51 +02:00
Alessandro Di Federico bce1d6c0f3 Adopt invalidation along the core pipeline 2024-06-20 10:24:50 +02:00
Alessandro Di Federico 5186a58053 s/FunctionMetadata/ControlFlowGraph/ 2024-06-18 17:56:24 +02:00
Pietro Fezzardi 80663458bb Pipeline: add loop-rotate, to match do-while loops 2024-06-06 11:27:48 +02:00
Djordje Todorovic 6941df12a3 Add SimplifySwitch Pipe 2024-05-29 16:27:52 +02:00
Lauri Vasama ba58ec8edb Add import-clift-types pipe 2024-05-29 15:43:35 +02:00
Lauri Vasama ba914a1bb5 Replace MLIR container and LLVM import pipe 2024-05-29 15:43:35 +02:00
Djordje Todorovic c58fec45e3 Add ImplicitModelCastPass
We introduce a new LLVM Pass that should detect implicit
casts, by marking the 3rd argument of ModelCast as `true`.
The backend will omit printing a cast expression if the
ModelCast is implicit one.
2024-05-16 17:57:22 +02:00
Alessandro Di Federico ddc4e7146f Run DropOpaqueReturnAddress after early-optimize 2024-05-03 18:09:12 +02:00
Alessandro Di Federico 452036edf1 Purge instructions to save return address 2024-04-30 15:25:53 +02:00
Pietro Fezzardi 71f61d9eb5 Pipeline: execute ExitSSA after ternary reduction 2024-03-19 09:44:00 +01:00
Pietro Fezzardi 132adeecd5 Add PeepholeOptimization pass
This pass is dedicated to applying a bunch of peephole optimizations
that are useful for decompilation and haven't been implemented in LLVM
for whatever reason.

At the moment it only runs an optimization that tries to reduce the uses
of incoming values of PHINodes, under very specific condidtions, which
enables emitting less LocalVariables.
2024-03-19 09:44:00 +01:00
Pietro Fezzardi 70c8ae48ff Retire MarkAssignment for SwitchToStatements 2024-03-19 09:44:00 +01:00
Alessandro Di Federico 0c212b66d9 Relicense to MIT 2024-02-29 17:03:36 +01:00
Ivan Krysak b0b1f10e72 ABI: move ToCABIFunctionType analysis to revng 2024-02-09 16:24:44 +01:00
Ivan Krysak 34039dea68 ABI: move ToCABIFunctionType analysis to revng 2024-02-09 16:07:59 +01:00
Alessandro Di Federico 346b367c19 Drop revng efa-extractcfg 2024-02-09 10:04:25 +01:00
Alessandro Di Federico d9367954a4 Convert all public strings to kebab-case 2024-02-09 10:04:24 +01:00
Alessandro Di Federico 2bdca8ab03 Rename steps and analyses 2024-02-09 10:04:22 +01:00
Alessandro Di Federico b4817a4f14 Rename pipelines file 2024-02-09 10:04:22 +01:00
Alessandro Di Federico f6f542769b Convert all public strings to kebab-case 2024-02-09 09:04:25 +01:00
Alessandro Di Federico 911ab00107 s/CDecompilation/Decompile/g 2024-02-09 09:03:34 +01:00
Alessandro Di Federico ba94f0ddd4 s/DecompiledToYAML/Decompiled/g 2024-02-09 09:03:34 +01:00