[cfe-dev] SSA form in Clang
mats at planetcatfish.com
Fri May 1 03:59:15 PDT 2015
You may want to copy the list on your replies (Reply All or similar), as
I'm by far no expert on how the analysis at AST level would work.
As they saying goes "The devil is in the detail", so a large part of the
actual answer to your question depends on "what optimisatons you plan to
do". I know there are people who work on/have worked on "source to source"
conversions, and (parts of) Clang can absolutely be used for this purpose.
Whether anyone has already done something that you can use, whether it does
exactly what you want or something similar is a further question, that I
haven't got the answer to.
On 1 May 2015 at 11:39, Hayden Livingston <halivingston at gmail.com> wrote:
> Yes, the point is to go over the C source code to generate optimized code.
> I'm using the CFG from Clang, but it's painful to generate SSA form. I
> don't have an algorithm, so I was hoping there would be a paper or
> well code that would be show me how to do it.
> On Fri, May 1, 2015 at 3:27 AM, mats petersson <mats at planetcatfish.com>
> > Someone will come along and correct me if I'm wrong, but my
> understanding is
> > that Clang does indeed rely very on LLVM to produce optimised code, and
> > little, if any, optimisation is done in Clang. Clang produces LLVM IR
> > directly from the AST (or at least "nearly directly", it does some
> > transformations in Sema for example, that introduces explicit casts from
> > implicit casts in the original source - such as converting integers to
> > or float to integer in arguments or assignments).
> > This is kind of the beauty of LLVM IR, and certainly helps the approach
> > taken in my Pascal compiler - of course, you still need to produce
> > "sensible" LLVM IR, as the optimisation will not remove all forms of
> > useless/stupid code that the user could create (as I've found out at
> > I have a hard time understanding why you couldn't use LLVM IR to make the
> > optimisations you want (by adding suitable passes to the compiler) - or
> > the point to output C source code that is "optimised"? If so, you may
> > to work at the AST level in Clang instead - there are tools for
> > iterating over that too.
> > --
> > Mats
> > On 1 May 2015 at 10:58, Hayden Livingston <halivingston at gmail.com>
> >> For my project (a subset of C) I'm trying to do optimizations at the
> >> source level language and wondering why Clang doesn't have an SSA form
> >> representation.
> >> Is it not useful, since LLVM does almost all the optimizations?
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev