Hi, This is really more a general compiler question, not so specific to LLVM. Given a set of pre-defined "primitive" functions, is there a way to un-inline function calls out of a function? (This is different from "extracting" functions because you are not allowed to create a new function, but only to use existing functions in the pool. These "primitive" functions are relatively simple.) One obvious application for this would be to extract llvm.instrinsics, memcpy() et al from equivalent loops. e.g: Original Function input to the un-inlining pass: int foo(int a, int b) { return mem[a] & mem[b]; } Pool of "primitive" functions: int get_mem(int a) { return mem[a]; } Output of un-inlining pass: int foo(int a, int b) { return get_mem(a) & get_mem(b); } I don't suppose LLVM has a pass for this yet; however, has anybody seen this done before? Can anybody point me to any existing work on these lines? Thanks! Nikhil
I found a book on this (http://www.amazon.com/Automatic-Algorithm- Recognition-Replacement-Optimization/dp/0262133687) on Amazon. Last I heard this was considered an intractable problem in the general case... but ad hoc solutions for specific functions (like memcpy) are possible. That book looks fairly promising. On Aug 7, 2007, at 10:32 AM, Nikhil A. Patil wrote:> Hi, > > This is really more a general compiler question, not so specific to > LLVM. > > Given a set of pre-defined "primitive" functions, is there a way to > un-inline function calls out of a function? (This is different from > "extracting" functions because you are not allowed to create a new > function, but only to use existing functions in the pool. These > "primitive" functions are relatively simple.) One obvious application > for this would be to extract llvm.instrinsics, memcpy() et al from > equivalent loops. > > e.g: > Original Function input to the un-inlining pass: > int foo(int a, int b) > { > return mem[a] & mem[b]; > } > > Pool of "primitive" functions: > int get_mem(int a) > { > return mem[a]; > } > > Output of un-inlining pass: > int foo(int a, int b) > { > return get_mem(a) & get_mem(b); > } > > I don't suppose LLVM has a pass for this yet; however, has anybody > seen this done before? Can anybody point me to any existing work on > these lines? > > Thanks! > Nikhil > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
This sounds a bit like a task of a de-compiler? Maybe you find hints on previous work in this area.
This book looks quite interesting. Thanks for the link! On 07/08/2007, Patrick Meredith <pmeredit at uiuc.edu> wrote:> I found a book on this (http://www.amazon.com/Automatic-Algorithm- > Recognition-Replacement-Optimization/dp/0262133687) on Amazon. > Last I heard this was considered an intractable problem in the > general case... but ad hoc solutions for specific functions > (like memcpy) are possible. That book looks fairly promising. > > On Aug 7, 2007, at 10:32 AM, Nikhil A. Patil wrote: > > > Hi, > > > > This is really more a general compiler question, not so specific to > > LLVM. > > > > Given a set of pre-defined "primitive" functions, is there a way to > > un-inline function calls out of a function? (This is different from > > "extracting" functions because you are not allowed to create a new > > function, but only to use existing functions in the pool. These > > "primitive" functions are relatively simple.) One obvious application > > for this would be to extract llvm.instrinsics, memcpy() et al from > > equivalent loops. > > > > e.g: > > Original Function input to the un-inlining pass: > > int foo(int a, int b) > > { > > return mem[a] & mem[b]; > > } > > > > Pool of "primitive" functions: > > int get_mem(int a) > > { > > return mem[a]; > > } > > > > Output of un-inlining pass: > > int foo(int a, int b) > > { > > return get_mem(a) & get_mem(b); > > } > > > > I don't suppose LLVM has a pass for this yet; however, has anybody > > seen this done before? Can anybody point me to any existing work on > > these lines? > > > > Thanks! > > Nikhil > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >