Hello, 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. +---------+ | | | ... | +-/-----\-+ +------------+ / \ | ... | +------/-+ +-\-------+ | | => | A1 | | A2 | | A | | | | | | ... | +------\-+ +-/-------+ +------------+ \ / +-\-----/-+ | | | ... | +---------+ Just to be more visual :) Instruction A get replaced by the basic blocks A1 and A2 that contain a sequence of instruction semantically equivalent to A. Alternative blocks shold be stored in a configuration file or something that can be easily changed. My original idea was to use an XML to store the alternatives using a lisp like language. For example: <xor> <alternative>(xor r1 r2)</alternative> <alternative> (and (or register1 register2) (not (and register1 register2))) </alternative> </xor> 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 :) Is there any way of doing this using the LLVM infrastructure in a simpler or more efficient way? Thank you for your time. Best regards Marco. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130309/ac65847f/attachment.sig>
Hello,> <xor> > <alternative>(xor r1 r2)</alternative> > <alternative> > (and (or register1 register2) (not (and register1 register2))) > </alternative> > </xor> > > 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 :) > > 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. Bye, speziale.ettore at gmail.com
Possibly Parallel Threads
- [LLVMdev] Code morphing pass.
- apcsmart: doesn't detect missing battery on Smart-UPS 2200 RM
- [LLVMdev] [PATCH][RFC] Allow target-specific morphing of intrinsics during SelectionDAG building
- [LLVMdev] ANN: libclc (OpenCL C library implementation)
- [LLVMdev] Building bitcode modules