`getUniqueString` returns a dedup'd char array `GlobalVariable` given a
string. We used to rely on named metadata to dedup them. However, this
lead to issues with `LLVMContainer` cloning and linking.
The new implementation uses the name of the variable as the
de-decuplication key, circumventing the problem entirely and improving
performance.
We used to turn `internal` linkage to the equivalent of C++'s inline.
We need to do the same for `private`. If we don't do this, the number of
`private` variables grows exponentially.
SegregateStackAccesses and PromoteStackPointer were not handling
functions declarated (but not defined) properly.
This commit fixes this, in part by adopting `TaggedFunctionPass`.
This commit introduces `BasicBlockID` as the unique identifier for a
`efa::BasicBlock` into the CFG. A `BasicBlockID` is defined by a
`MetaAddress` plus an incremental integer. This enables us to have
multiple instances of the same block in a single function, which is
particularly useful when inlining multiple times the same function.
Apart from this, the commit also does the following:
* It drops representing `MetaAddress`es a `structs` in the IR. This created
several issues related to ABI. We now represent them as strings.
* It defines more functions in `support.h`, instead of defining prototypes
by hand in `CodeGenerator.cpp` and the like. Specifically, `unknownPC`
and `raise_exception_helper`. We also introduce a C "constructor" for
`PlainMetaAddress`.
* It significantly reduces the API of `GeneratedCodeBasicInfo`, which
was supposed to be put on a diet since a long time. Specifically,
many jump target related methods have been moved to free functions in
`IRHelpers.h`. Also `GCBI::getSuccessors` has been pushed into its
only user, `PruneRetSuccessors`, to prevent further usage of a
deprecated API. In the future, it would be nice to drop it entirely.
* It introduces `efa::BasicBlock::InlinedFrom`.
* Introduce an enum to represent named argument indices for `newpc`.
This enables us to more effectively manipulate its argument list.
* It improves the verification and error reporting for
`efa::FunctionMetadata`.
* Update tests.
This commit is preliminary to another piece of work to improve the
generality of inlining beyond the simple "fake function" scenario, for
which the feature was originally conceived.
TrackingContainer is a wrapper around KeyedObjectContainers (notably,
SortedVector) intended to figure out which elements of the underlying
container have been accessed.
`DocumentError`s are the inteded way of propagating errors from the
pipeline to the frontend when a location is required to inform the user
of the error whereabouts.
Using a named metadata is simply wrong, because we need to have many of
these metadata alive at the same time with different values.
Using a named metadata has the unpleasant side effect of making all the
`SegmentRef` functions to refer to the same segment.
This change fixes the pipeline behavior when producing targets:
* produce and extract now return rp_buffer, which has a start pointer
and size
* the python api `revng.api` will return on produce/extract either str
or bytes depending on the mime type of the container
* the GraphQL api will encode bytes in base64
To keep consistency with the rest of PipelineC, return `nullptr` when
calling `rp_container_extract_one` when the content of the specified
target hasn't been produced
A logic issue existed in the Pipe, as it was mistakenly relying on
`IsolatedRoot` instead of the isolated function. That was breaking
things if those functions were to be removed. This issue has been
addressed by correcting the behaviour of the Pipe.
`ReadOnlyContainers` is defined to be a `llvm::StringMap`
of a further `llvm::StringMap` of `std::unique_ptr`s of
`ContainerBase`. A logic issue has been addressed by
properly dereferincing the inner map.
A logic issue existed when validating whether a `cl::opt<T>`
was set. This has been addressed by replacing `isDefaultOption`
method with `getNumOccurrences`, as the former one was not
meant to be used for checking if the option was set or not.
Likewise, the default Option itself is written to a `std::string`,
in method `get`; the latter is leveraged by `Invokable`.
Compute the weight of collpased regions the first time it is requested
and cache it, and use the cached value for all successive queries.
This also prevents a bug which occurs when we query the weight two
times for the same collapsed node, whose related collapsed region object
has been in the meantime destroyed by the tiling process.
This commit does various things oriented at reducing the number of local
variables emitted in C:
- MarkAssignments now know that @Copy and @Assign involving
@LocalVariable only have side effects that affect the local variable
itself; this enables to reduce the number of times we're forced to
emit a local variable due to interfering side effects
- Drop the @AssignmentMarker FunctionTag; AddAssignmentMarkerPass now
doesn't emit @AssignmentMarker anymore; instead it emits groups of
@LocalVariable, @Copy, and @Assign, which benefit from the previous
point
- Drop 2 MarkAssignments::Reasons: HasManyUses and HasUsesOutsideOfBB;
both these have now been aggregated into the AlwaysAssign reason for
simplicity, representing all reasons non involving side effects
- Update BeautifyGHAST and how it reasons about side effects when
beautifying; before this commit it used @AssignmentMarker, now it
looks at @Assign
- Simplify ExitSSA; before this commit it was trying hard to be smart on
where it emitted the store instructions representing the incoming
values of the PHI that was being destroyed; this seemed smart when we
originally did it but it generated C code that was not really better
to read, so this useless complexity is finally gone
`TupleTreeReference`s use the Root type as a pointer only so they can
operate with forward declarations. Before this commit there were static
asserts that prevented this use case, and thus required the headers
defining the root type to be included before this one to work correctly.
We drop those `static_assert`s to make sure that all headers are parsable
on their own.