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'
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.
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.
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.
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.
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.
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.
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.
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
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.