Code morphing pass


for an university course I am working on a code morphing pass. The idea
is that a random vector gets generated at the entry point of functions
and that vector will be used to randomize the flow of execution.

Alternative flows are built looking at the instructions inside the basic
blocks of the function and for some of them replacing the orginal
instruction with a set of logically equivalent basic blocks.


<alternative>(xor r1 r2)</alternative>
   (and (or register1 register2) (not (and register1 register2)))

Parsing the string inside the alternative blocks I should be able to
build basic blocks that contain a sequence of instruction semantically
equivalent to the original one. And here is my question :slight_smile:

Is there any way of doing this using the LLVM infrastructure in a
simpler or more efficient way?

You can write a TableGen tool to lex and parse your file. The syntax
of the config file will be different, but in this way you have only to
implement semantic analysis.