[cfe-dev] SSA form in Clang

mats petersson mats at planetcatfish.com
Fri May 1 03:27:22 PDT 2015


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
very 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
float or float to integer in arguments or assignments).

This is kind of the beauty of LLVM IR, and certainly helps the approach
I've 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 times).

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 was
the point to output C source code that is "optimised"? If so, you may want
to work at the AST level in Clang instead - there are tools for
(recusively) iterating over that too.

--
Mats

On 1 May 2015 at 10:58, Hayden Livingston <halivingston at gmail.com> wrote:

> 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...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150501/d584f730/attachment.html>


More information about the cfe-dev mailing list