Commit Graph

2302 Commits

Author SHA1 Message Date
Alessandro Di Federico c5c657d11b Lift: increase determinism 2025-04-15 15:31:10 +02:00
Giacomo Vercesi e6fcca3dc6 TupleTreeContainer: fix infinite recursion
Fix an infinite recursion caused by renaming the `ContainerBase::load`
function to `ContainerBase::loadImpl`.
2025-04-07 10:35:20 +02:00
Giacomo Vercesi 11f1e532c6 Implement dirty bit on Container
Add a `Dirty` boolean to the `ContainerBase` class. This will be set to
true when the container mutates itself (e.g. remove, mergeBack, clear).
The dirty bit is reset when running `PipelineManager.store`.
2025-04-03 15:59:18 +02:00
Giacomo Vercesi f740badd68 PipelineManager: drop storeContext
The `storeContext` function was a misguided attempt to performance
optimization. Without storing all the containers and the invalidation
metadata the resume directory would be corrupt by just storing the
context.
2025-04-03 15:59:18 +02:00
Andrea Gussoni 40ebac06cc IDS: introduce pass
Introduce the `inline-divergent-scopes` pass. This pass in is charge of
reducing the exit nodes in a `ScopeGraph`, applying the _Inline
Divergent Scopes_ transformation, which is able, in presence of
divergent exits nodes, wrt. to a conditional, to remove the exit node
and to transform the `ScopeGraph` in a form where semantics is
preserved.
2025-04-02 16:47:14 +02:00
Andrea Gussoni 47fac0d948 SelectScope: introduce pass
Introduce the `select-scope` pass. This pass is in charge of enforcing
the relative decidedness property for all the nodes in the `ScopeGraph`,
wrt. to all the conditional nodes. It does this by applying the
relative decidedness definition, electing one scope for each conditional
node in the graph, and by transforming all the edges that would violate
the property into goto edges.
2025-04-02 16:47:14 +02:00
Andrea Gussoni 21be052d6f ScopeGraph: introduce the makeGotoEdge helper
Introduce the `makeGotoEdge` helper to the `ScopeGraphBuilder` class,
that can be used to handle the transformation of a solid edge into a
`goto` edge, taking care of the creation of the `goto` block and the
redirection of the edges.
2025-04-02 16:47:14 +02:00
Andrea Gussoni 1482a5e110 ScopeGraph: improve ScopeGraph .dot name
Include the function name in the filename of the dumped `.dot` of the
`ScopeGraph`.
2025-04-02 16:47:14 +02:00
Andrea Gussoni a7e58b2749 GraphAlgorithms: improve return type
Improve the definition of the return type of `nodesBetween`, obtaining
the type of the elements in the `Set`s by passing through the
`GraphTraits::NodeRef` type, which enables us to handle more generic
situations, where `GraphT` includes a `View` over a graph.
2025-04-02 16:47:14 +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 c85275cc70 Add expression region utilities in CliftOps.h 2025-03-24 09:26:43 +02:00
Lauri Vasama b97c55980b Change Clift type constraints to ValueType
clift.indirection %p : <8 to !int32_t>

The concrete type kinds would cause types in the assembly to be emitted
without type mnemonics. See the example above.
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 5bd481ae5a Overhaul clift.function assembly syntax
Old syntax:
```
        unique_handle = "/model-type/1",
        name = "my_function",
        return_type = !t,
        argument_types = [
                !t
        ]
>
```

New syntax:
```
        "/model-type/1" as "my_function" : !t(!t)
>
```

* Rename clift.function mnemonic to clift.func.
2025-03-24 09:26:43 +02:00
Lauri Vasama 281bf283e2 Overhaul clift.typedef assembly syntax
Old syntax:
```
	unique_handle = "/model-type/1",
	name = "my_typedef",
	underlying_type = !t
>
```

New syntax:
```
	"/model-type/1" as "my_typedef" : !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 8482bcbf90 Overhaul clift.defined assembly syntax
Old syntax:
```
!clift.defined<#t>
!clift.defined<is_const = true, #t>
```

New syntax:
```
!clift.defined<#t>
!clift.defined<const #t>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 64fc21e9dd Overhaul clift.pointer assembly syntax
Old syntax:
```
!clift.pointer<pointer_size = 8, pointee_type = !t>
!clift.pointer<is_const = true, pointer_size = 8, pointee_type = !t>
```

New syntax:
```
!clift.ptr<8 to !t>
!clift.ptr<const 8 to !t>
```
2025-03-24 09:26:43 +02:00
Lauri Vasama 872b157774 Overhaul clift.array assembly syntax
Old syntax:
```
!clift.array<elements_count = 42, element_type = !t>
```

New syntax:
```
!clift.array<42 x !t>
```
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 8f44ebe12d Improve Clift type constraint error messages 2025-03-24 09:26:43 +02:00
Lauri Vasama 23b47f825e Add Clift AggregateOp 2025-03-24 09:17:38 +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 df2003efb8 Add clift::removeConst in CliftTypes.h 2025-03-19 12:57:20 +02:00
Lauri Vasama da9df369fc Loosen Clift logical op type constraints 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 c472dd3cae Move ScopedExchange to revng/ADT/ 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
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 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 41e2e0f73d RunTraceOptions: use doxygen comments
Change the struct field comments on the
`revng::tracing::RunTraceOptions` struct to doxygen comments.
2025-03-13 16:23:21 +01:00
Giacomo Vercesi 6eae722d5b tracing::Argument: make ArgumentState enum private
Move the `ArgumentState` enum to be a private member of the `Argument`
class, since no external users require using the enum.
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 72d9b46e4b Error.h: improve joinErrors
Change the `joinError` functions to have stronger guarantees when used:
* Change the template signature to `RangeOf` to ensure that the
  container has `llvm::Error`s.
* Check that the size of the passed container is actually positive
  before deferencing `.begin()`.
2025-03-13 15:07:25 +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 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 fe127200be GraphAlgorithms: improve comments 2025-03-11 12:25:24 +01:00
Andrea Gussoni ec8972cbed ScopeGraph: require pointer type for ScopeGraph 2025-03-11 12:25:23 +01:00