Custom opcodes that are tagged AllocatesLocalVariable never have
arguments that should be replaced with SegmentRef or cstringLiteral.
Constant arguments or those custom opcodes are actually used to encode
another kinds of informations so they should be preserved.
This commit prevents that replacements to happen.
This commit changes MakeSegmentRefPass so that it's now a ModulePass and
it uses the binary to detect integer constants that represent the
address of strings.
When it detects address of constant strings, instead of injecting calls
to SegmentRef, we now inject calls to cstringLiteral, so that we can
later emit them as inline string literals in C.
In segmentRef we use integer type meaning address in memory, so we
generate segmentRef function with non-pointer type. For cstringLiteral
function we need real pointer type of operand.
Save MetaAddress, size, offset and original type for every
cstringLiteral call in metadata as we do for segmentRef calls.
For cstringLiteral "revng.cstring_literal" metadata name is used.
StringLiteralPool needs tuple of address, size, offset and type to
keep distinct string decorator functions for each string. This tuple is
represented by StringLiteralPoolKey struct.
Pipe for MakeSegmentRefPass needs to be defined explicitly, because
additional wrapper passes are required in MakeSegmentRef:
1. LoadModelWrapperPass
2. LoadBinaryWrapperPass
MakeSegmentRefPass requires access to RawBinaryView to detect cstring
literals in binary.
Fix printed command in MakeSegmentRefPipe
This printed command might not work. @ale commented it will be replaced
with `revng pipe run-pipe` once we will have it.
Update IRHelpers to new revng API
Switch String and Namespace arguments in getUniqueString
Using a named metadata is simply wrong, because we need to have many of
these metadata alive at the same time with different values.
Using a named metadata has the unpleasant side effect of making all the
`SegmentRef` functions to refer to the same segment.
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.