[cfe-dev] Implementing front-end of a user-directed optimization

Michael Kruse via cfe-dev cfe-dev at lists.llvm.org
Thu Jun 11 11:26:54 PDT 2020


Am Do., 11. Juni 2020 um 13:06 Uhr schrieb Richard Smith
<richard at metafoo.co.uk>:
>> For (1), there a TreeTransform to transform an AST subtree into
>> another one. This an approach I took for
>> https://reviews.llvm.org/D76342
>
>
> This approach is generally not in line with clang's design philosophy and should be avoided where feasible. (If you need to do semantic analysis on the result of the transformation, then it's typically not feasible to avoid it; in such cases the best we can do is to retain both the original source form and the (minimally) desugared form. But that should typically not be necessary for an optimization.)

It is also my less preferable option. However, in D76342 (which keeps
the original source and the desugared form) I have done so because the
desugared AST can be used as input for OpenMP loop directives; it's
semantic analyzer takes a substatement as input. Unfortunately most of
the logic for OpenMP loop directives is implemented in the semantic
analyzer (generating AST expressions) instead of in CodeGen. To some
extend this is unavoidable because iterator overloaded operators need
to be resolved in the desugared form. However, once D76342 is
greenlit, I'd work an moving more of the loop directive logic into
CodeGen.

I added you as a reviewer of D76342. Would you be interested in reviewing it?

Michael


More information about the cfe-dev mailing list