Bruce Hoult
2014-Jun-12 20:43 UTC
[LLVMdev] A question about running Clang after LLVM passes
However, LLVM can output using the C back end ... which you can then feed into Clang. On Fri, Jun 13, 2014 at 3:58 AM, Eli Bendersky <eliben at google.com> wrote:> > > > On Wed, Jun 11, 2014 at 12:41 AM, Padefic <padefic at 126.com> wrote: > >> Hello, >> >> Clang is used before LLVM to generate IR, and is it possible to use it in >> a reverse way, i.e., after running LLVM passes, we can run clang again to >> use LLVM pass results? If so, should I write clang functions in LLVM >> passes, or write LLVM pass requirements in clang? >> >> Thank you in advance! >> > > > Clang does not consume LLVM IR, so the answer is no. What are you trying > to do? > > Eli > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140613/0042acee/attachment.html>
I am doing a research project. I want to run the DSA pass of LLVM, and use its result in Clang for automatic fixing. I have to use Clang because the line numbers in Clang are accurate so that I can change code accordingly, while LLVM IR seems to lose the information. I need to access the objects created in LLVM pass to get information. Thank Bruce for your advice, could you explain more about how to output using the C backend? Does it mean to output to files, which then input into Clang? I would appreciate any reference on this problem. In addition, it seems that by directly running command "clang -Xclang -load -Xclang mypass.so", we can run llvm pass with clang automatically. So is it a possible way to hack into clang and do something after the LLVM-pass-related code? Thanks! At 2014-06-13 04:43:15, "Bruce Hoult" <bruce at hoult.org> wrote: However, LLVM can output using the C back end ... which you can then feed into Clang. On Fri, Jun 13, 2014 at 3:58 AM, Eli Bendersky <eliben at google.com> wrote: On Wed, Jun 11, 2014 at 12:41 AM, Padefic <padefic at 126.com> wrote: Hello, Clang is used before LLVM to generate IR, and is it possible to use it in a reverse way, i.e., after running LLVM passes, we can run clang again to use LLVM pass results? If so, should I write clang functions in LLVM passes, or write LLVM pass requirements in clang? Thank you in advance! Clang does not consume LLVM IR, so the answer is no. What are you trying to do? Eli _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140613/5ee9b35a/attachment.html>
John Criswell
2014-Jun-13 14:13 UTC
[LLVMdev] A question about running Clang after LLVM passes
On 6/12/14, 9:29 PM, Padefic wrote:> I am doing a research project. I want to run the DSA pass of LLVM, and > use its result in Clang for automatic fixing. I have to use Clang > because the line numbers in Clang are accurate so that I can change > code accordingly, while LLVM IR seems to lose the information.If I understand what you're saying, you're building a refactoring tool that does some analysis on the program and then changes the original program's source code. Is this correct? I do not think that this is a good idea. DSA operates on the LLVM IR. Not only will you have the headache of making DSA's results available to Clang, but Clang "sees" the program at the Clang AST level while DSA "sees" the program at the LLVM IR level. Mapping DSA's results from the LLVM IR back to the AST that Clang creates will be painful in the best case and will probably not work reliably at all in the worst case. I think your best option is to build a points-to analysis that works at the Clang AST level and put it into clang directly. There might be the issue of how to build an inter-procedural points-to analysis with Clang, but I think there either is a way for Clang to do that, or there is work to make Clang do that.> > I need to access the objects created in LLVM pass to get information. > Thank Bruce for your advice, could you explain more about how to > output using the C backend? Does it mean to output to files, which > then input into Clang? I would appreciate any reference on this problem.The C Backend generates C code instead of native assembly code. The C code it generates is ugly and looks almost nothing like the original C source code that was compiled. Again, if you're building a refactoring tool, this is probably not what you want. Regards, John Criswell -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140613/a45dff4a/attachment.html>
Reasonably Related Threads
- [LLVMdev] A question about running Clang after LLVM passes
- [LLVMdev] A question about running Clang after LLVM passes
- [LLVMdev] llvm DSA - reproduce the result in PLDI 07 paper
- [LLVMdev] Status of poolalloc, and in particular DSA
- [LLVMdev] Questions bout the Steensguard AA Pass in rDSA