The simplifyLastContinue beautifier was too ambitious and there were
many corner cases that it handled in the wrong way, leaving the AST in a
shape that could not be emitted, or breaking the semantics.
This commit severely weakens the simplifyLastContinue, so that it does
not break things anymore.
It is now able to match only continue statements that are in the last
position of a sequence node which is the body of a ScsNode.
This obviously is not enough but allows revng-c to pass all the
decompilation tests.
In the future we will need to extend simplifyLastContinue to match more
cases in a sane way.
This commit moves the matching of short-circuited ifs before the stage
of flipping if nodes with emtpy then.
This is necessary because the if short-circuiting may produce if nodes
with empty then, which can be then flipped by the next beautify step.
Before this commit, we couldn't handle simplification of atomic
sequences in cases of switches that had a default.
The reason is that if you remove a case from a switch that has a
default, you are implicitly saying that the case that you remove will be
handled by the default, hence you're changing the semantics.
Now we handle this case by not removing the case, substituting it with a
SwitchBreak node instead.
Remove from the `RegionCFGTreeImpl.h` header the helper functions used
for the first AST simplification that are now part of the
`GenerateAst.h` header.
Count the number of duplication (needed later in the `Mark` pass) right
before the AST generation phase, where the `RegionCFG` will be destroyed
by the tiling matching.
Change the interface of the `findReachableNodes` helper function, so
that now accepts arguments passed by pointer instead of by reference.
Also, the helper function now does not accept a `nullptr` `Source`
parameter.
The `Successors` and `Predecessors` field on the `BasicBlockNode` are
now promoted from being a `std::pair` composed by the pointer to the
successor and the set representing the cases, to a pair between the
pointer to the successor and a new struct called `EdgeInfo`.
This struct is used to contain both the information about the cases, the
information representing whether and edge is inlined or not, and
possibly more information in the future.
Under certain conditions, we ended up having code in the ABI IR which
was not reachable. This was due to the fact that a certain instruction
was initially detected as an indirect call, triggering inclusion in the
function of the fallthrough code, and then as a return, which has no
successors within the function.
This commit simply prunes the ABI IR in the finalization method.
This commit fixes the detection of the revng-c include file in build
directory, using the PathList facility provided by revng.
Before this commit, running revng-c from build directory failed to
properly identify the revng-c include if it was not already installed
but only available in the build directory itself.
EnforceABI promotes global variables representing parts of the CPU
states to arguments and return values of isolated functions.
This commit enables the promotion of CSV that are used in isolated
functions only indirectly, through `ConstantExpr`s casts.
Before this commit, the original llvm BasicBlock was not embedded
properly in the GHAST SwitchNodes. This caused problems and crashes in
decompilation.
This commit SwitchNode constructors so the that the BasicBlock properly
reaches the GHAST and it is printed correctly by the decompiler.
Before this commit, the C statements before an IfNode or a SwitchNode
were not guaranteed to be emitted if they were not involved in the
computation of the branch condition.
This commit fixes this problem.