Commit Graph

6113 Commits

Author SHA1 Message Date
Ivan Krysak 5779cd878d KOCs: make more STL-like
This adds a couple of newer methods missing from these templates.
2023-07-02 15:06:11 +00:00
Ivan Krysak 4ab4d85ead STLExtras: remove incomplete iterator concepts 2023-07-02 15:06:11 +00:00
Ivan Krysak 690df84eca Concepts: prefer non-strict SpecializationOf
Not every case can benefit from extra liniency, so they were manually
reviewed on a case by case basis.

Additionally, this drops a couple of "this should be a non-strict
specialization" commits, because of a bug with clang
(see the GenericGraph concepts rework commit for more details) as
to avoid confusion (we wouldn't want anyone trying to solve these
"todo"s) until the clang struct type deduction is fixed. Especially
considering that there are currently no cases where these softer
versions would be beneficial (we never inherit from templates in
question).
2023-07-02 15:06:11 +00:00
Ivan Krysak 37b8f80bf1 Concepts: introduce SpecializationOf
It was not available earlier because it required clang-13+
2023-07-02 17:05:52 +02:00
Ivan Krysak b927e26f94 Drop concepts provided by the standard library
We needed these because our libc++ version didn't provide them. Now that
that's no longer the case, they can be safely dropped.
2023-07-02 13:20:49 +02:00
Ivan Krysak a123ec2c35 Remove clang-format off around concepts
Now that clang-format no longer breaks anything involving a concept or
a requires clause on sight, these are no longer necessary
2023-07-02 13:20:49 +02:00
Ivan Krysak d0e174497b Formatting: change PenaltyBreakOpenParenthesis
The new value is `800000`, same as that of
`PenaltyBreakBeforeFirstCallParameter`.

Currenly there are no cases where this is relevant in the codebase
(since it was not allowed), so here's an artificial one to illustrate
the situation:

(behaviour before this commit)
```
  auto x = short_whatever(
    whatever_but_the_name_is_long("first", "second", "a long argument"));
```
(behaviour after this commit)
```
  auto x = short_whatever(whatever_but_the_name_is_long("first",
                                                        "second",
                                                        "a long argument"));
```
2023-07-02 13:20:49 +02:00
Ivan Krysak bc98e0079f Formatting: change PenaltyReturnTypeOnItsOwnLine
The new value is 21.
2023-07-02 13:20:49 +02:00
Ivan Krysak 01b4ec36c9 Formatting: set AllowShortEnumsOnASingleLine
The new value is `false`.
2023-07-02 13:15:08 +02:00
Ivan Krysak c523167302 Formatting: enforce access modifier whitespaces 2023-07-02 13:09:52 +02:00
Ivan Krysak f198f67e87 Formatting: set LineEnding to LF 2023-07-02 11:06:55 +00:00
Ivan Krysak 6c668d6820 Formatting: set InsertNewlineAtEOF to true 2023-07-02 11:06:55 +00:00
Ivan Krysak aabc22a388 Update clang-format-style-file
Fill all the missing options based on their values from
`clang-format-16`'s `llvm` configuration.
2023-07-02 11:06:55 +00:00
Ivan Krysak 6e2d222c23 Formatting: update deprecated options
Updates options include
- `ConstructorInitializerAllOnOneLineOrOnePerLine: true`
  - became `PackConstructorInitializers: NextLine`
2023-07-02 11:06:55 +00:00
Ivan Krysak 0e061aedc4 Make clang-format-style-file a YAML file 2023-07-02 11:06:55 +00:00
Ivan Krysak 7ed14ca65c Minor improvements 2023-07-02 11:06:55 +00:00
Alessandro Di Federico 5885e4f9c8 ValueMaterializer: fix handling of ptr 2023-06-30 16:57:33 +02:00
Alessandro Di Federico 56d43ff089 Isolate/Enforce: add nomerge to calls
Isolated functions already have the `nomerge` attribute, but calls do
not.  This is important in presence of indirect calls.
2023-06-30 16:54:01 +02:00
Alessandro Di Federico 5273aaa15c check-conventions: handle one line commits 2023-06-30 15:05:27 +02:00
Alessandro Di Federico e97501abc4 Merge branch 'feature/value-materializer' 2023-06-30 14:41:58 +02:00
Alessandro Di Federico a65ccc3413 Introduce ValueMaterializer
`ValueMaterializer` is a rewrite of what was called `AdvancedValueInfo`
which follows the same principles.

The main benefits over the old version is:

* We materialize the data-flow graph and the CFG of the relevant part of
  root. This makes debugging significantly easier.
* We drop the old MonotoneFramework infrastructure in favor of
  getMaximalFixedPoint.
* We significantly reduce the amount of queries we make to
  AdvancedValueInfo.
2023-06-30 13:39:22 +02:00
Alessandro Di Federico 4c01d9c28d BidirectionalNode: implement edge removal 2023-06-30 13:38:27 +02:00
Alessandro Di Federico 4edcb6dd49 MetaAddress::decomposeIntegerPC: accept APInt 2023-06-30 13:35:04 +02:00
Alessandro Di Federico 466871e866 Introduce RegisterClobberer 2023-06-30 13:28:36 +02:00
Alessandro Di Federico f120ad334c Statistics.h: rework 2023-06-30 13:06:58 +02:00
Alessandro Di Federico 5e72f8e31b ConstantRangeSet::dump: custom APInt formatter 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 08b8b0bd9f ConstantRangeSet::size: fix corner case
In order to correctly represent the size of a 32-bit ConstantRange, you
need 33 bits.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico b21861b7f9 GraphTraits<GenericGraph>: fix const support
GraphTraits were not fully usable in case of a `const` graph due to a
missing std::conditional_t for the definition of the `Node` type.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico 6ca6692d1e getUniqueJumpTarget: do not abort if PC unwritten
Sometimes code performs an indirect jump without changing the value of
the PC.  In most cases this is due to non-code or some other faulty
situation, but it is in principle possible that an instruction performs
an indirect branch to its own address.

This commit ensures that this situation does not end up in an hard
failure.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico 3706f77960 LDDTree: mark Logger static 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 5ebec631b9 getMaximalFixedPoint: fix Flow argument type 2023-06-30 12:35:18 +02:00
Ivan Krysak e3be901f1f STLExtras: allow skip to result in empty ranges
This only affects the case where the number of elements to be skipped
exactly matches the number of elements in the container.
2023-06-30 12:35:18 +02:00
Alessandro Di Federico d3c37fc692 ProgramCounterHandler::expandNewPC: take CallBase 2023-06-30 12:35:18 +02:00
Alessandro Di Federico b8b2fcff71 GenericGraph tests: zero initialize EdgeLabel::X 2023-06-30 12:35:18 +02:00
Alessandro Di Federico 84dd10cbdb GenerichGraph.h: nullptr-initialize Edge::Neighbor 2023-06-30 12:35:18 +02:00
Alessandro Di Federico b53d3f457b Minor changes 2023-06-30 12:35:18 +02:00
Pietro Fezzardi 8505a7222b Merge branch 'feature/fix-test-list' 2023-06-30 10:49:14 +02:00
Pietro Fezzardi c06f963fe1 Test recompilation for i386 separately
This is necessary because i386 has weird sizes for `long double` that
result in `float86_t` in the model, so we need to pass additional
arguments to the recompilation tests, in order to avoid compiler errors.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi d9b5bfd99a revng-primitive-types.h: improve generic{80,96}_t
Before this commit, both `generic80_t` and `generic96_t` were always
defined as structs containing an array of chars of the proper size.

This ensured that they always had the proper size, but it didn't play
well with recompilation of decompiled C code, because it wasn't possible
to assign e.g. a `float80_t` to a `generic80_t` (or viceversa), which
was the whole point of having `generic80_t` and `generic96_t`.

This commit works around this by making sure that, whenever `float80_t`
(and `float96_t`) is defined, the definition of `generic80_t` (and
respectively of `generic96_t`) always matches, allowing error-free
recompilation of decompiled sources.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi 6bc5346733 Rename tests in revng-c-model-to-header.yml
This change is intended for the name not to clash with another set of
tests that lives in revng-c.yml.
The first is intended as a set of unittests for model-to-header,
the second is intended to generated headers to test recompilation of
decompiled C code.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi eae5e3069d revng-primitive-types.h: fix 128-bits definitions
This commit guards 128-bits integer typedefs and helpers with:
`#ifdef __SIZEOF_INT128_`, because these are compiler extensions that
are not always guaranteed to be defined (e.g. they are not available
when compiling for x86 32-bits).
2023-06-30 10:48:59 +02:00
Pietro Fezzardi 1b4079b496 DecompileFunction.cpp: HTML-escape strings in PTML 2023-06-30 10:48:59 +02:00
Pietro Fezzardi dd3836112d DecompileFunction.cpp: handle enum comparisons 2023-06-30 10:48:59 +02:00
Pietro Fezzardi 6acd265c5a Add revng helpers to decompile llvm::UndefValue
Before this commit, we used to decomple UndefValue to the literal 0.

This was causing problems in some cases, such as switch(0 /*undef*/)
where clang was issuing a warning that was impossible do disable without
turning off -Wall alltogether, which is undesirable.

This commit introduces a set of helper functions in
revng-primitive-types.h, that are now used to avoid emitting undef as
constant.
This is more semantically meaningful when looking at the decompiled
code, and it has the nice side effect that it silences the clang
warnings mentioned above.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi e988932442 DecompileFunction.cpp: fix 128 bit literals 2023-06-30 10:48:59 +02:00
Pietro Fezzardi 01a985632f OperatorPrecedence: support OpaqueExtractValue 2023-06-30 10:48:59 +02:00
Pietro Fezzardi e2791443fb Remove extractvalue instructions in decompilation
Now extractvalue instruction are replaced by dedicated
OpaqueExtractValue custom opcode, that prevents LLVM from doing strange
things with extractvalues during optimizations (such as e.g. sinking).

This is important since extractvalue instructions and struct-typed
values in general in our LLVM IR are not real first-class citizens, but
only a byproduct of the binary lifting process, and they actually
represent bundles of registers that are returned from isolated
functions.
2023-06-30 10:48:59 +02:00
Pietro Fezzardi e4315c2cf0 FoldModelGEP: update transparent opcodes 2023-06-30 10:48:59 +02:00
Pietro Fezzardi cb02af692a FunctionTags::OpaqueExtractValue: add attributes
This commit adds the following attributes to OpaqueExtractValue:
- nounwind
- willreturn
- inaccessiblememonly
2023-06-30 10:48:59 +02:00
Pietro Fezzardi ce576870a5 FunctionTags: drop old unused FunctionTags::Marker 2023-06-30 10:48:59 +02:00