Commit Graph

6113 Commits

Author SHA1 Message Date
Pietro Fezzardi 31db946bd3 TypeInlineHelper: refactor collectStackTypes
Now collectStackTypes is implemented as a wrapper on top of
findTypesToInlineInStacks.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 4106617f6c Backend: better const-correctness for inline types 2024-05-29 15:34:26 +02:00
Pietro Fezzardi 196a15685f Rename TypeInlineHelper::findStackTypesPerFunction
to TypeInlineHelper::findTypesToInlineInStacks, which is more
descriptive of what the method actually does.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 93a821a64a Backend: assert that the stack is defined once 2024-05-29 15:34:26 +02:00
Pietro Fezzardi f1fedf4e4e Drop unused TypeInlineHelper::getTypeToNumOfRefs 2024-05-29 15:34:26 +02:00
Pietro Fezzardi d9fddc4933 Early exit from isReachableFromRootType
Before this commit, TypeInlineHelper would always visit all the types to
compute reachability.
Now it bails out early, as soon as it detects reachability.
2024-05-29 15:34:26 +02:00
Alessandro Di Federico e22ea4b2d8 Minor changes 2024-05-29 12:23:32 +02:00
Alessandro Di Federico 84e3fac538 Minor changes 2024-05-29 12:06:03 +02:00
Alessandro Di Federico 666696808f Merge branch 'feature/drop-sections' 2024-05-22 15:02:06 +02:00
Alessandro Di Federico 330eb32921 Merge branch 'feature/drop-sections' 2024-05-22 15:02:03 +02:00
Alessandro Di Federico 47c3dd8f0f Drop model::Segment::Sections 2024-05-22 10:25:25 +02:00
Alessandro Di Federico 0377ed6c04 StdStorageClient::type: always return Missing 2024-05-22 10:25:25 +02:00
Alessandro Di Federico f35ca5efc2 for-collect-cfg.yml: make tests more robust 2024-05-22 10:25:25 +02:00
Alessandro Di Federico 31b1b66f44 Reorder model::Binary fields 2024-05-22 10:25:25 +02:00
Alessandro Di Federico efe381e839 Improve failed precondition checks reporting 2024-05-22 10:25:25 +02:00
Alessandro Di Federico 3be8f4c3d3 Lift: require DefaultABI or DefaultPrototype 2024-05-22 10:25:25 +02:00
Alessandro Di Federico c061f1f971 Make Pipe::checkPrecondition mandatory 2024-05-22 10:25:25 +02:00
Alessandro Di Federico 738da4fbb5 Minor changes 2024-05-22 10:25:25 +02:00
Alessandro Di Federico 9eb4726989 decompilation.yml: split off revng-c.decompilation 2024-05-21 09:44:04 +02:00
Alessandro Di Federico 22c97bce6b Drop model::Segment::Sections 2024-05-21 09:44:04 +02:00
Alessandro Di Federico b05ab6ff3c Make Pipe::checkPrecondition mandatory 2024-05-21 09:44:04 +02:00
Pietro Fezzardi f3daba6ec5 Merge branch 'feature/reduce-C-casts' 2024-05-16 18:25:25 +02:00
Djordje Todorovic 0f46ec5578 Add tests for C cast expressions 2024-05-16 17:57:22 +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
Djordje Todorovic 39f513f9b5 MakeModelCast: replace SExt ZExt Trunc 2024-05-16 17:57:22 +02:00
Djordje Todorovic c4eda86471 MakeModelCast: Change OpaqueFunctionsPool
Introduce new key: use TypePair instead of Type *.
2024-05-16 17:57:22 +02:00
Djordje Todorovic dd68f7d810 Move casts to MakeModelCastPass
Production of casts in backend should be indicated by
call to ModelCast only. This patch implements that.
2024-05-16 17:57:22 +02:00
Djordje Todorovic e3f191ff67 doc: Adjust tests because of cast reduction 2024-05-16 17:55:19 +02:00
Alessandro Di Federico e64eee9402 CodeGenerator: handle partially valid instructions
Sometimes we have instructions that are, say, two bytes long but only
one of the two bytes are invalid (because they end up out of the
segment).
2024-05-15 13:19:42 +02:00
Alessandro Di Federico b273caa8dc FunctionMetadata::findBlock: do not ignore IBDHB 2024-05-15 13:19:42 +02:00
Alessandro Di Federico 38ea8f5237 Handle calls to non-functions 2024-05-15 13:19:40 +02:00
Pietro Fezzardi 6d3b6452ae Merge branch 'feature/fix-stack-available-exprs' 2024-05-14 18:21:07 +02:00
Pietro Fezzardi d102835490 Fix stack aliasing in AvailableExpressionAnalysis
Before this commit, the AvailableExpressionAnalysis used by
SwitchToStatements did not take into account the full set of custom
opcodes that allocate local variables.

In particular, if only checked FunctionTags::LocalVariable, and not the
larger set marked with the tag FunctionTags::AllocatesLocalVariable,
which includes revng_stack_frame and revng_call_stack_arguments.

This caused all the reasoning on aliasing that involved the stack to be
broken.

This commit fixes the problem by properly using the
FunctionTags::AllocatesLocalVariable to reason about aliasing.
2024-05-14 18:20:50 +02:00
Pietro Fezzardi 223fa4a7ed Fix InstructionToSerializePicker on MemoryRead
Before this commit, the InstructionToSerializePicker had a wrong bailout
condition, that caused to never pick for serialization memory reads.

This was wrong and caused semantic bugs, due to the instruction
performing the memory read not being serialized into a new variable.
2024-05-14 18:20:50 +02:00
Pietro Fezzardi 1fac9d0586 Fix mayReadMemory for stack custom opcodes
Before this commit, the mayReadMemory helper function was broken for
the two custom opcode functions used to model stack variables:
revng_stack_frame and revng_call_stack_arguments.

This means that those two functions were already considered as reading
memory, while the actually do not.

This commit fixes that, so that mayReadMemory now always properly
returns false for them.
2024-05-14 18:20:50 +02:00
Pietro Fezzardi c8cd6dd784 Merge branch 'feature/fix-inline-switch' 2024-05-08 21:19:33 +02:00
Andrea Gussoni 6af6c8ffa8 RemoveDeadCode: dead code removal beautify
We introduce a "dead code" optimization like pass on the AST.

The goal is to simplify away, in a `SequenceNode`, everything that
follows a node with sports a `nofallthrough behavior.
2024-05-07 14:17:05 +02:00
Andrea Gussoni a6e96dcb93 FallThroughScope: remove SwitchBreak type
A `SwitchBreak` node should not have a specific associated
`FallThroughScopeType`, since its semantics represent the fact of a
`case` of the `switch` with no associated statements, and thus can be
represented with the `FallThrough` behavior.
2024-05-07 14:17:05 +02:00
Andrea Gussoni 54e656ce62 FallThroughScope: dispatcher switch fallthroughs
Change the analysis in order to lift the assumption that a dispatcher
`switch` always coveris all the values of the variable state. This is
not true after the `simplifySwitchBreak` and `inlineDispatcherSwitch`
beautify passes, which can remove some of the `case`s.
2024-05-07 14:17:05 +02:00
Andrea Gussoni d05f0eb498 FallThroughScope: ScsNodes do fallthrough
The `FallThroughScope` associated to a `ScsNode` should represent the
fact that we have fallthrough from a loop.

Without any more advanced semantical analysis, we cannot conclude that
we do not have fallthrough.
2024-05-07 14:17:05 +02:00
Andrea Gussoni 3763d781d3 InlineDispatcherSwitch: improve function signature 2024-05-07 14:17:05 +02:00
Andrea Gussoni 8d7beaf332 InlineDispatcherSwitch: remove SetNodes
During the `SwitchBreakSimplify` pass, we also remove the `SetNode`s
associated to `case` simplified.
2024-05-07 14:17:05 +02:00
Andrea Gussoni 6b5b2ee5f5 InlineDispatcherSwitch: do not inline non local CF
Do not inline loop related `break` and `continue` statements.
Indeed, inlining them would mean moving from the scope of a cycle, to an
inner one, non-local control flow statements, and this would break the
semantics.
2024-05-07 14:16:45 +02:00
Andrea Gussoni e926a80e1c InlineDispatcherSwitch: remove non-exercised code 2024-05-07 14:01:56 +02:00
Andrea Gussoni 1ceda0e8cb ASTNode: STL practice consistency 2024-05-07 14:01:56 +02:00
Andrea Gussoni 67e7b54eda BeautifyGHAST: reorder SwitchBreaksFixer pass
Delay the `SwitchBreaksFixer` beautify pass run.
Specifically, we run it last, as this pass computes information used
only by the backend, and the information it depends upon may be
invalidated by some passes that transform `switch`es (as the
`simplifyDualSwitch` pass).
2024-05-07 09:18:20 +02:00
Andrea Gussoni 0fb60b5c0c BeautifyGHAST: remove unused using 2024-05-07 09:18:20 +02:00
Alessandro Di Federico 31344a3270 Add missing includes 2024-05-03 21:55:33 +02:00
Alessandro Di Federico 4eb44e3555 Merge branch 'feature/improve-build-times' 2024-05-03 21:53:42 +02:00
Alessandro Di Federico bf6cefc05a Externalize functions to improve build times 2024-05-03 21:52:40 +02:00