Ali Javadi
2013-May-08 13:37 UTC
[LLVMdev] clone function with constant argument, and constant fold it
Hi, I'm writing a pass that collects some information from functions, but this requires constant propagation/constant folding to be done on those functions beforehand. However some of these functions have an integer argument that can take certain constant values, and the functions are always called with these constant values at their various call sites. What I'm trying to do is to look at the call site, see what the constant argument is, and propagate that into the function. I don't want to alter the function (this is purely an analysis pass), so I want to create a copy of the function beforehand (using cloning), pass the constant argument to the new copy, and perform constant folding/dead code elimination on it. Then I can do my analysis on this new, constant folded version of the original function, collect my information, and then discard it (Move on to the next call site with possibly a new constant). Does this seem like a reasonable approach? To me this seems like a combination of function cloning, interprocedural constant propagation and dead code elimination that llvm has. Is there an easy way of using these (or certain functions of them) to perform this task, or do I just have to borrow pieces of code from them? Any suggestion/advice would be appreciated. Ali -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130508/bbb89c29/attachment.html>
Maybe Matching Threads
- [LLVMdev] freeing alloca'd variables before function exits
- [LLVMdev] c-like language implementation using llvm
- [LLVMdev] freeing alloca'd variables before function exits
- [LLVMdev] c-like language implementation using llvm
- [LLVMdev] A small pass to constant fold branch conditions in destination blocks