Commit Graph

74 Commits

Author SHA1 Message Date
Pietro Fezzardi a263270858 Remove redundant casts on comparisons 2023-06-09 09:28:40 +02:00
Pietro Fezzardi 74df82e0ca model-to-header tests: silence bogus warnings
This commit adds the '.h' suffix to the headers used for testing
model-to-header. This enables clang to understand that they are C
headers and suppresses a set of bogus warnings that were otherwise
triggered as -Wunused-command-line-argument.

Namely, the unused arguments it complained about were:
* 'linker'
* '-c'
* '-ferror-limit=0'
* '-I'
2023-05-12 15:21:22 +02:00
Giacomo Vercesi a4ad571e61 rcc: Fix typos
Fix the typos detected by `codespell`
2023-05-11 10:04:32 +02:00
Alessandro Di Federico 7b2e7a9312 Adopt new revng-qa sources handling 2023-05-10 14:23:32 +02:00
Djordje Todorovic 9d94216dc5 ModelToHeader: Add testing infrastructure
Test structs, unions and primitive types.
Also add tests for inline types.
2023-05-03 13:13:28 +02:00
Djordje Todorovic 41678f8cb6 compile-flags: Avoid warnings on unused local typedefs
Before inline types, majority of typedefs were global,
so  we did not have this problem. But from now on, we have
some typedefs that are local to functions that may be
unused, and it is recognized by compilers as a warning.
2023-05-03 13:13:28 +02:00
Pietro Fezzardi 17cbe341c6 Remove DuplicateReferences from pipeline
The pass was necessary to prevent the creation of local variables with
reference types, caused by calls to custom opcodes tagged with
FunctionTags::IsRef.
These local variables would not be valid for decompilation, because C
doesn't have reference types.
However, creation of such variables would pop up if not deduplicated,
due to the fact these calls could have many uses, and MarkAssignments
had a policy of marking for serialization all the instructions with many
uses.
Now that policy has been dropped, so this pass doesn't need to exist
anymore.
2023-04-20 17:51:16 +02:00
Alessandro Di Federico 79c2ca38f6 Introduce SplitOverflowIntrinsicsPass
This pass splits calls `*.with.overflow*` intrinsics into the a pair of
instructions: the underlying operation and a call to an `Helper`-tagged
function that computes whether such operation overflowed.

For instance, we go from:

    %2 = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %0, i32 %1)
    %3 = extractvalue { i32, i1 } %2, 1
    br i1 %3, label %..., label %...

To:

    %2 = mul i32 %0, %1
    %3 = call i1 @mul_overflow_u32(i32 %0, i32 %1)
    br i1 %3, label %..., label %...

This saves from handling `struct` in the backend.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico 43a0be786f helpers-to-header tests: start from canonicalized 2023-04-14 14:54:14 +02:00
Alessandro Di Federico 8860ea16e2 Introduce HoistStructPhis
This pass turns phis of invocations of pure functions into an invocation
of the pure functions with one phis per argument of the original
invocations.

This makes handling phis easier in the backend and is necessary after
the introduction of simplify-cfg with sinking enabled.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico ffee4c22f0 Adapt tests to LLVM 16 2023-04-14 14:54:14 +02:00
Alessandro Di Federico ccb660646e Introduce SimplifyCFGWithHoistAndSinkPass
This is a simple pass that enables running simplify-cfg with the legacy
pass manager enabling instruction hoisting and sinking.
2023-04-14 14:54:14 +02:00
Alessandro Di Federico fda84a701f Decompilation: suppress more warnings 2023-04-14 14:54:14 +02:00
Pietro Fezzardi fe7df1ae75 Add -Wno-pointer-sign to compile-flags.cfg
Now that we support C string literals, by the rules of the language they
have type `const char [N]` where `N` is a compile time constant.
They also decay to `const char *`.

This causes the `-Wpointer-sign` warning to trigger when recompiling
decompiled C code, since we assign the string literals (with type `const
char *` in C) to variables with other pointer types, some of which are
e.g. `const uint8_t * but possibly also `const generic8_t *`.

Given that we emit C code from assembly this warning is too strict to be
always enforced.
In fact, we had already disabled a similar warnings, such as
`-Wincompatible-pointer-types`, and others.
So we disable `-Wpointer-sign` as well in recompilation tests.
2023-04-04 09:31:10 +02:00
Kacper Kołodziej daead39e60 Check signedness of char in revng-primitive-types.h 2023-04-04 09:31:10 +02:00
Kacper Kołodziej 3038dd179f Add binary to MakeSegmentRefs containers in pipeline
Additional argument (--binary) in some tests is needed, because
MakeSegmentRefPipe requires access to binary file.
2023-04-04 09:31:10 +02:00
Massimo Fioravanti d9bbe33316 Add initial autoanalysis 2023-03-22 17:25:05 +01:00
Ivan Krysak e52a07a657 revng-primitive-types.h: fix a typo 2023-03-15 10:28:24 +01:00
Ivan Krysak f5c50da449 Tests: reorder the analyses to import first
The primitives were imported before the importing of the binary, which
is not valid anymore since it leads to duplicate types in cases where
the binary contains any primitive types, since one of the revng-side
commit now asserts on an attempt to insert multiples of the same type.

Also, this removes a duplicated type from the `SegregateStackAccesses`
test's `override` model.
2023-03-15 10:28:24 +01:00
Ivan Krysak eb34c2ee1f Pipes: add ConvertToCABIFunctionType analysis 2023-03-15 10:28:24 +01:00
Ivan Krysak 64d83c89c4 Testing: use the new temp file generator 2023-03-15 10:28:24 +01:00
Andrea Gussoni 1a5f48f4d9 Add simplifycfg pass in the opt pipeline 2023-01-13 14:21:02 +01:00
Kacper Kołodziej 83ab07d7fb Enable printing integers as bool, hex or char
This commit adds a new pass, PrettyIntFormatting, that injects calls to
decorator functions print_hex, print_char, and print_bool around
llvm::ConstantInt in various situations.

It also updates the rest of passes of the decompilation pipelin to
understand these new decorator functions and to properly emit decorated
integer literals in the decompiled C code.
2022-12-02 10:08:00 +01:00
Alessandro Di Federico 049b8657c3 Introduce RemoveStackAlignmentPass 2022-12-01 12:20:09 +01:00
Alessandro Di Federico 00bc0b594b Segregate tests: run full decompilation
This is just for regression testing purposes, we need to have proper
testing on the emitted C.
2022-11-30 18:16:13 +01:00
Alessandro Di Federico 080a7ae442 Test returning aggregates 2022-11-30 18:16:13 +01:00
Alessandro Di Federico c5ab81cd08 Segregate: handle aggregate return values 2022-11-30 18:16:13 +01:00
Alessandro Di Federico 39c673a4c4 Rework tests 2022-11-30 18:16:13 +01:00
Pietro Fezzardi 1bec5bd2ab Define all primitive types in dedicated header
This commit does the following:
- drops revngfloat.h
- disables printing primitive types in ModelToHeader
- creates a new header revng-primitive-types.h which includes all the
  declarations of all revng primitive types
2022-11-30 18:16:13 +01:00
Pietro Fezzardi 38cb917b87 Revive RemoveLLVMAssumeCallsPass
This pass remove calls to `llvm.assume` which are introduced by stack
promotion for stack alignment.
2022-11-10 12:07:37 +01:00
Djordje Todorovic ee8eb9e697 Adding LoopRewriteWithCanonicalIV LoopPass 2022-10-21 15:56:13 +02:00
Pietro Fezzardi 31da8c5891 Update to new revng ptml cli 2022-09-29 18:38:11 +02:00
Alessandro Di Federico f8867f9220 Give pretty names to temporary files 2022-09-26 16:52:41 +02:00
Giacomo Vercesi 8e996d2394 Output PTML in revng-c
Change the output of the backend of revng-c to PTML
2022-09-01 16:59:29 +02:00
Massimo Fioravanti 36da1ced9f revng pipeline: handle new syntax for targets 2022-08-09 12:25:56 +02:00
Massimo Fioravanti bd1a4aab95 revng pipeline: handle new --produce argument 2022-08-09 12:25:56 +02:00
Massimo Fioravanti 5efda4640d revng pipeline: handle new syntax for outputs 2022-08-09 12:25:56 +02:00
Alessandro Di Federico c15fae2065 CheckDLA.ll: fix ground truth
* `model::Function::Type` no longer exists
* We dropped `IndirectCall` edge type in favor of simply `FunctionCall`
2022-08-08 16:22:14 +02:00
Djordje Todorovic 929bb58e68 Handle float80 type
This was needed in order to handle some PDB files.
2022-07-29 09:24:21 +02:00
Antonio Frighetto cb2df465fa Recompilation: add type mismatch flags 2022-07-19 13:54:28 +02:00
Antonio Frighetto d9bc64b29d Introduce MakeSegmentRefPass
A simple pass that scans constant expressions and literals and
replaces them with opaque calls so that they can be easily dealt
with by the Backend, in an attempt of emitting better-looking
decompiled code.
2022-07-19 13:48:50 +02:00
Giacomo Vercesi 661821b45c Add SingleTargetFilename to pipelines
Add SingleTargetFilename for pipeline artifacts
2022-06-28 11:26:40 +02:00
Giacomo Vercesi 29d55849c5 Sync formatting changes
revng-check-conventions now includes the use of prettier for
formatting yaml files.
2022-06-28 11:25:56 +02:00
Alvise de Faveri d98db76ce1 IRCanonicalization: Add DuplicateReferences pass
This pass adds robustness to the IRCanonicalization pipeline. It
ensures that no reference opcode has more than one use.
2022-06-28 10:30:32 +02:00
Alvise de Faveri f3b2bf2e2d IRCanonicalization: Remove early-cse 2022-06-28 10:29:54 +02:00
Alvise de Faveri 562df4f288 Recompilation: Add -Wno-return-stack-address 2022-06-28 10:29:42 +02:00
Alvise de Faveri 6b258c83a1 IRCanonicalization: Fold ModelGEP(AddressOf())
- `FoldModelGEP` folds `ModelGEP(AddressOf())` into `ModelGEPRef`
- `RemoveRefDeref` remove `ModelGEPRef`s with no arguments
2022-06-28 10:26:50 +02:00
Alvise de Faveri 123a1777cd IRCanonicalization: Add RemoveLoadStore pass 2022-06-28 10:25:49 +02:00
Alvise de Faveri f7866ddd85 IRCanonicalization: Add MakeLocalVariables pass 2022-06-28 10:24:48 +02:00
Alvise de Faveri 221b8f74d9 Add reference semantics to stack opcodes
`revng_stack_frame` and `revng_stack_args` are treated as returning
a reference, and are always followed by an `AddressOf` call.
2022-06-28 10:23:45 +02:00