[LLVMdev] Source-to-Source transformations

Konstantis Daloukas konstantis.daloukas at gmail.com
Tue Sep 29 02:27:02 PDT 2009

Dear LLVM Members,

I have started using LLVM for my project two weeks ago and I would be 
grateful if you could give me some information for writing a 
source-to-source transformation pass. More specifically, I want to apply 
a source-level transformation is some functions of my input program in 
order to create work chunks. For example, given the following function:
    void foo() {

       /* some work */

I would like to modify it in the following:

    void foo() {

       int i = work_size();

       for ( int j = 0; j < i; j++ ) {

          /* some work */



So, the first thing I would like to know is how to create some local 
variables in a given function while the second is how to insert a for 
statement in the body of a function.

Thanks a lot in advance,

More information about the llvm-dev mailing list