<div dir="ltr">Hi Laurin,<div><br><div>I'm not really familiar with clang/LLVM backends, but here's a guess.</div><div><br></div><div>The simplest idea is to change the existing code that parses the file and generates diagnostics.</div><div>At least to prototype, I think you might want to change clangd::ClangdFrontendAction (in ClangdUnit.cpp) to subclass clang::EmitCodeGenOnlyAction (or one of the other CodeGenActions) instead of clang::SyntaxOnlyAction. And then add the relevant flags.</div></div><div><br></div><div>However I'm not sure that's going to work well:</div><div> - with the backend enabled, everything is going to get a lot slower</div><div> - we have optimizations (like not parsing function bodies in the preamble) that probably aren't compatible with codegen</div><div> - doing codegen is probably going to force clang to deserialize all of the preamble, which is also slow</div><div> - obviously it means linking in the backend, which is quite a big thing for a release build if this is a niche feature</div><div><br></div><div>For performance, I'm not sure how feasible it is to run codegen for code directly referenced by the main file only (again, not a backend person!), this would be the analogue to how we keep frontend diagnostics fast.</div><div><br></div><div>We have a vague wish to support some more-expensive diagnostics (template expansions, clang-tidy analysis) that can't be computed every loop, but haven't come up with a good design yet.</div><div><br></div><div>Cheers, Sam</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Sep 17, 2018 at 2:24 PM Laurin Brandner via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org">clangd-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">Hi,
<div><br></div>
<div>I’m fairly new to this community so I hope I’m not asking a very trivial question.</div>
<div>Anyways, I’m looking into the possibility of returning optimization remarks like the option -Rpass=loop-vectorize would do. By looking at clangd’s source code I realized that clangd only preprocesses the project but does not really invoke the backend.</div>
<div>Thus, I would like to implement an action that enables the output of optimization remarks. Could I maybe get some guidance on to what I need to do to achieve this? I saw that I most likely need to subclass Action but I’m not quite sure what subclass I should have a closer look at. </div>
<div><br></div>
<div>Thanks a lot for any kind of help.</div>
</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><br>
Cheers,
<div>Laurin</div>
</div>
</div>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote></div>