[llvm-dev] Understanding optimizations below LLVM IR.
Krzysztof Parzyszek via llvm-dev
llvm-dev at lists.llvm.org
Sun Sep 2 10:00:00 PDT 2018
On 9/2/2018 10:42 AM, James Courtier-Dutton via llvm-dev wrote:
>
> I am writing a de-compiler "Binary -> LLVM IR". So, I obviously need to
> treat SBB as a special case and transform it into something that can be
> represented in LLVM IR.
Not a "special case", it's just an instruction whose function needs to
be represented in the LLVM IR somehow.
> I wish to obtain a list of all the optimizations done by LLVM that
> result in assembly that cannot immediately be represented in LLVM IR.
That won't take you anywhere.
Think of this as a compiler that takes source programs in ELF format
(for example) and produces output in .ll format. The resulting .ll will
never look exactly like the original bitcode, the best you can get is
that it will have the same semantics. The SBB instruction uses the carry
bit and modifies the carry bit, so you need to represent the carry in
your bitcode model somehow, and then do just that: write bitcode that
produces the result of the subtraction and the value of the simulated
carry bit. For things like EFLAGS are difficult to model because they
are like a global variable, but if you assume some default value of it
at function entries, you can still "decompile" functions that use it.
-Krzysztof
More information about the llvm-dev
mailing list