Commit Graph

3168 Commits

Author SHA1 Message Date
Lauri Vasama 50252c0ec6 Fix no-op asserts 2024-05-29 15:43:35 +02:00
Lauri Vasama 38c0605e76 Fix error message in StructType::parse 2024-05-29 15:43:35 +02:00
Lauri Vasama 25c4710c9a Fix EnumAttr::verify
* Fix enumerator value strict ordering check.
* Remove enumerator name uniqueness check.
2024-05-29 15:43:35 +02:00
Lauri Vasama 786740f935 Fix PointerType::verify
Allow pointers with sizes 4 or 8, matching the model.
2024-05-29 15:43:35 +02:00
Lauri Vasama c24f40ad43 Add missing verify functions 2024-05-29 15:43:35 +02:00
Lauri Vasama 73187864ee Fix UnionType::verify
* Add field type completeness check.
* Remove field name uniqueness check.
2024-05-29 15:43:35 +02:00
Lauri Vasama 5341c2bb0a Fix StructType::verify
* Simplify offset and size checks.
* Add field type completeness check.
* Remove field name uniqueness check.
2024-05-29 15:43:35 +02:00
Lauri Vasama 3a547889a3 Move struct,union get,getChecked defs to .cpp
There seem to be some issues with defining these in headers due to the
storage type being incomplete. The storage type is only defined in the
.cpp file.
2024-05-29 15:43:35 +02:00
Lauri Vasama e9cacbc613 Replace unsigned long with uint64_t 2024-05-29 15:43:35 +02:00
Lauri Vasama 9730b00e88 Remove UnionType::verify size parameter 2024-05-29 15:43:35 +02:00
Lauri Vasama 689b7b08f8 Add TODO on add_mlir_dialect_library 2024-05-29 15:43:35 +02:00
Lauri Vasama e2f3f31093 Introduce RawFunctionType::Architecture 2024-05-29 15:43:35 +02:00
Lauri Vasama d49a06bf25 Fix spelling of DefaultRawType 2024-05-29 15:43:35 +02:00
Lauri Vasama c20c1e9e85 Fix spelling of FunctionEntryMDName 2024-05-29 15:43:35 +02:00
Lauri Vasama 3e33a300d5 Introduce RawFunctionType::Architecture 2024-05-29 15:42:15 +02:00
Lauri Vasama 185afcf4c0 Fix spelling of FunctionEntryMDName 2024-05-29 15:42:15 +02:00
Pietro Fezzardi e1a59e527a TypeNames: fix missing trailing \n in PTML comment
The missing \n was causing following type declaration to be wrongly
commented out.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi 2ee2577152 TypeInlineHelper: drop unused getTypeGraph method 2024-05-29 15:34:26 +02:00
Pietro Fezzardi 746cf5b55d TypeInlineHelper: rename collectStackTypes method
to collectTypesInlinableInStacks and document it.
2024-05-29 15:34:26 +02:00
Pietro Fezzardi df9d7215b5 TypeInlineHelper: remove unnecessary members
`TypeToNumOfRefs` was used only in one method, so it can be computed
directly there on the fly.

`calculateNumOfOccurrences` doesn't need to be a method (it can be a
free function), it doesn't need to run at construction time, and it
doesn't need to return a map. So it's been moved in the `.cpp` file,
renamed to `getCrossReferencedTypes` and changed to return a set. It is
now only called when needed.
2024-05-29 15:34:26 +02:00
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 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 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 b05ab6ff3c Make Pipe::checkPrecondition mandatory 2024-05-21 09:44:04 +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
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 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
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