Commit Graph

3084 Commits

Author SHA1 Message Date
Giacomo Vercesi 1aa9c61c31 LocalStorageClient: save filelist
When saving to disk, `LocalStorageClient` will also save a file named
`file_list.yml` which will list the list of files, which is needed for
downstream save handlers to efficently save.
2025-03-27 12:45:29 +01:00
Giacomo Vercesi f99aee6cf6 StorageClient: disable S3StorageClient
Disable creation of `S3StorageClient` from
`StorageClient::fromPathOrURL`.
2025-03-26 16:36:20 +01:00
Lauri Vasama 3ca3653333 Convert Clift type handles to use locations 2025-03-24 09:27:57 +02:00
Lauri Vasama d6a2ee387e Add aliases for Clift types without handles 2025-03-24 09:26:43 +02:00
Lauri Vasama e9c329e51d Rename Clift unique handle to handle 2025-03-24 09:26:43 +02:00
Lauri Vasama 1325c75979 Move Clift op custom parsers out of header 2025-03-24 09:26:43 +02:00
Lauri Vasama 5479a5de88 Add special handling of aggregate initializers 2025-03-24 09:26:43 +02:00
Lauri Vasama c85275cc70 Add expression region utilities in CliftOps.h 2025-03-24 09:26:43 +02:00
Lauri Vasama 2f64025dc9 Fix Clift backend double negation emission 2025-03-24 09:26:43 +02:00
Lauri Vasama 5f475739ef Rename reinterpret, add convert cast 2025-03-24 09:26:43 +02:00
Lauri Vasama f884642f59 Overhaul clift.struct, clift.union assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_struct",
	size = 2,
	fields = [
		<
			offset = 0
			name = "",
			type = !t
		>,
		<
			offset = 1,
			name = "my_field",
			type = !t
		>
	]
>

	unique_handle = "/model-type/1",
	name = "my_union",
	fields = [
		<
			offset = 0,
			name = "",
			type = !t
		>,
		<
			offset = 0,
			name = "my_field",
			type = !t
		>
	]
>
```

New syntax:
```
	"/model-type/1" as "my_struct" : size(1) {
		offset(0) : !t,
		offset(1) as "my_field" : !t
	}
>

	"/model-type/1" as "my_union" : {
		!t,
		"my_field" : !t
	}
>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama ea78766f10 Overhaul clift.enum assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_enum",
	underlying_type = !t,
	fields = [
		<
			name = "my_enumerator",
			raw_value = 42
		>
	]
>
```

New syntax:
```
	"/model-type/1" as "my_enum" : !t {
		42 as "my_enumerator"
	}
>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama eaf1bf35aa Overhaul clift.primitive assembly syntax
Old syntax:
```
!clift.primitive<SignedKind 8>
!clift.primitive<is_const = true, SignedKind 8>
```

New syntax:
```
!clift.primitive<signed 8>
!clift.primitive<const signed 8>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama e2f4af30e9 Add custom builder for Clift FunctionOp 2025-03-24 09:26:43 +02:00
Lauri Vasama e08a8e766b Set register set type name in Clift import 2025-03-24 09:26:43 +02:00
Lauri Vasama 20cb57a105 Fix redundant cast parentheses in Clift backend 2025-03-24 09:26:42 +02:00
Lauri Vasama a9727e198c Fix return statement emission in Clift backend 2025-03-24 09:25:30 +02:00
Lauri Vasama 0df1056fe8 Add Clift backend support for UndefOp 2025-03-24 09:25:30 +02:00
Lauri Vasama 23b47f825e Add Clift AggregateOp 2025-03-24 09:17:38 +02:00
Lauri Vasama bf625c631a Improve Clift CallOp syntax 2025-03-24 09:17:36 +02:00
Lauri Vasama 1b63797640 Add Clift TernaryOp 2025-03-19 12:57:22 +02:00
Lauri Vasama 747a792f0f Add Clift pointer arithmetic ops 2025-03-19 12:57:22 +02:00
Lauri Vasama 66246218b7 Add Clift StringOp 2025-03-19 12:57:21 +02:00
Lauri Vasama ee3deb5d3f Add model verification in clift-opt 2025-03-19 12:57:21 +02:00
Lauri Vasama 8163933eb4 Add linefeeds in clift-opt emit-c 2025-03-19 12:57:21 +02:00
Lauri Vasama 888d529d93 Fix Clift return type verification 2025-03-19 12:57:20 +02:00
Lauri Vasama df2003efb8 Add clift::removeConst in CliftTypes.h 2025-03-19 12:57:20 +02:00
Lauri Vasama 4a334bef7b Move Clift type helpers to CliftTypes.h 2025-03-19 12:57:19 +02:00
Lauri Vasama eec882dac1 Add clift::GlobalOpInterface 2025-03-19 12:57:19 +02:00
Lauri Vasama 44c9388930 Rename Clift comparison operations 2025-03-19 12:57:18 +02:00
Lauri Vasama 08c2c0a477 Remove ScalarTupleType
After converting type IDs to unique handles it was decided to remove
scalar tuple types in favour of generated structs with non-model unique
handles.
2025-03-19 12:57:18 +02:00
Lauri Vasama 386efffb2f Convert TypeDefinitionAttr ID to UniqueHandle 2025-03-19 12:57:17 +02:00
Lauri Vasama 86126db366 Fix Clift composite type verify on parsing 2025-03-19 12:57:17 +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
Alessandro Di Federico 86f3dcf1ae Minor changes 2025-03-14 17:25:05 +01:00
Giacomo Vercesi a9a0fdc236 ELFImport: fix input file missing
When using revng through `revng daemon` the variable `InputPath` is not
populated, leading to `lddtree` failing silently. Fall back to the input
binary in the resume directory in case the the `InputPath` variable is
empty.
2025-03-14 13:05:39 +01:00
Giacomo Vercesi 6cdf6b9eda DebugInfo: do --verbose if logger is enabled
Enable running `fetch-debuginfo` in verbose mode if the logger is
enabled.
2025-03-13 18:03:50 +01:00
Giacomo Vercesi 87872f9fc5 PipelineManager: add save-after-every-analysis
Add a command-line option to pipeline that saves after every analysis is
run.
2025-03-13 18:03:50 +01:00
Giacomo Vercesi 74eba2954f revng trace run: log commands before execution
Log the commands that are going to be executed by `revng trace run` on
the `trace-runner` logger.
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 042108bc44 ProgramRunner: cleanup
Clean up the `ProgramRunner` class:
* use llvm-provided wrappers and system-agnostic variables to compute
  the `Paths` variable
* pre-compute the list of path variables so it's not re-computed on
  every invocation of `run` or `isProgramAvailable`
* Wrap the logging code so that it's not triggered if the logger is
  disabled
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 442020bf22 ProgramRunner: print exit code to logger
Print the exit code of the invoked program to the `program-runner`
logger.
2025-03-13 15:16:17 +01:00
Giacomo Vercesi 51687a2f4f Runner.cpp: remove extra ; 2025-03-13 15:16:17 +01:00
Giacomo Vercesi 5b00a93660 revng trace run: skip setting credentials
The `rp_manager_set_storage_credentials` is now skipped when running a
trace in `revng trace run`. This is needed because the storage backend
when running a trace is replaced with a local one and calling the
function does not make sense.
2025-03-13 15:09:15 +01:00
Andrea Gussoni 93f4a620dd DAGify: implement the DAGify pass
Implement the DAGify pass. This pass, using the results exposed by the
`GenericRegionInfo` analysis, transforms all the retreating edges of
each identified `GenericRegion`, processed in a bottom-up fashion, into
a `goto` edge on the `ScopeGraph`.
2025-03-11 12:26:36 +01:00
Andrea Gussoni d5b26a9346 GenericRegion: add support for ScopeGraph
Add the needed support for running `GenericRegionInfo` on the
`ScopeGraph`.

This needs a new ad-hoc `getGenericCycleInfo` helper in order to unwrap
the `Graph` object (pointing to the underlying `Function *`) from the
`Scope` wrapper object.
2025-03-11 12:25:24 +01:00
Andrea Gussoni 3499d10154 GenericRegion: remove retreatings edges
Remove retreating edges from the `GenericRegion` class, and the
collection of them in `GenericRegionInfo`.
2025-03-11 12:25:24 +01:00
Andrea Gussoni f5b3feb738 ESE: fix comment 2025-03-11 12:25:24 +01:00
Pietro Fezzardi 405001d628 CCodeGenerator::getModelGEPToken: relax assumption
This commit relaxes the assumption of the
CCodeGenerator::getModelGEPToken method, that previously crashed if the
BaseType and CurType were different.
Now this condition is only checked after skipping all typedefs, that
are transparent to ModelGEPs.
2025-03-05 15:25:59 +01:00
Pietro Fezzardi e87a229b1c DecompileFunction: use __builtin_bit_cast
This commit ensures that, when the LLVM-based C code generation emits a
bitcast that would not compile in C if printed as a regular cast, it
uses __builtin_bit_cast instead.

This is necessary because the LLVM-based C backend is deprecated in
favor of the clift-based decompilation pipeline, so we're not actively
fixing bugs anymore, and it currently cannot guarantee that such invalid
casts are never emitted.
2025-03-05 15:25:59 +01:00
Pietro Fezzardi f13e919678 MakeModelCastPass: allow casting non-scalars
Before this commit, MakeModelCastPass was assuming that it would never
try to emit casts involving non-scalars, which don't compile in C.

From now on, the semantic of ModelCast in understood to be bitcast, and
it's valid also when involving non-scalar types.
This may cause the emission of ModelCast that are then emitted in C as
casts that don't compile.
Since the LLVM-based decompilation pipeline is deprecated in favor of
the clift-based decompilation pipeline, this is now considered
acceptable, as long as the C backend prints a warning and a comment on
the broken cast.
2025-03-05 14:47:46 +01:00