<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"></div><div dir="ltr">Why do you want to use clangd for this rather than clang itself? You will need to effectively perform full compiles for this which is clang’s job. (The remarks are emitted by the various optimization passes *as* LLVM runs them.)</div><div dir="ltr"><br></div><div dir="ltr">Adam</div><div dir="ltr"><br></div><div dir="ltr"><br>On Sep 20, 2018, at 2:16 AM, Laurin Brandner <<a href="mailto:mail@laurinbrandner.ch">mail@laurinbrandner.ch</a>> wrote:<br><br></div><blockquote type="cite"><div dir="ltr">
<title></title>
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">Hi Jan,
<div><br></div>
<div>Essentially, I want to create a vs code extension that annotates the code to display various optimization remarks. So for example, I would like to highlight a loop which clang wasn’t able to vectorize. Thus, I’m now trying to make clangd invoke the backend as well. </div>
<div><br></div>
<div>Could you maybe share some hints that I can look into to make this work? Thank you very much in any case :)</div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;"><br>
Cheers,
<div>Laurin</div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">On 19 Sep 2018, 17:43 +0200, Jan Korous <<a href="mailto:jkorous@apple.com">jkorous@apple.com</a>>, wrote:<br>
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #1abc9c;">
<div class="">+backend guys</div>
<div class=""><br class=""></div>
<div class="">Hi Laurin,</div>
<div class=""><br class=""></div>
<div class="">Would you mind sharing more details about your project? What is your goal here?</div>
<div class=""><br class=""></div>
<div class="">Cheers,</div>
<div class=""><br class=""></div>
<div class="">Jan<br class="">
<div><br class="">
<blockquote type="cite" class="" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #e67e22;">
<div class="">On 18 Sep 2018, at 15:13, Laurin Brandner via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">Hi Sam,
<div class=""><br class=""></div>
<div class="">Thank you very much for your help. I will prototype this and see where it goes :)</div>
</div>
<div name="messageSignatureSection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class=""><br class="">
Cheers,
<div class="">Laurin</div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">On 17 Sep 2018, 16:43 +0200, Sam McCall <<a href="mailto:sammccall@google.com" class="">sammccall@google.com</a>>, wrote:<br class="">
<blockquote type="cite" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #3498db;" class="">
<div dir="ltr" class="">Hi Laurin,
<div class=""><br class="">
<div class="">I'm not really familiar with clang/LLVM backends, but here's a guess.</div>
<div class=""><br class=""></div>
<div class="">The simplest idea is to change the existing code that parses the file and generates diagnostics.</div>
<div class="">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 class=""><br class=""></div>
<div class="">However I'm not sure that's going to work well:</div>
<div class=""> - with the backend enabled, everything is going to get a lot slower</div>
<div class=""> - we have optimizations (like not parsing function bodies in the preamble) that probably aren't compatible with codegen</div>
<div class=""> - doing codegen is probably going to force clang to deserialize all of the preamble, which is also slow</div>
<div class=""> - 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 class=""><br class=""></div>
<div class="">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 class=""><br class=""></div>
<div class="">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 class=""><br class=""></div>
<div class="">Cheers, Sam</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Mon, Sep 17, 2018 at 2:24 PM Laurin Brandner via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a>> wrote:<br class=""></div>
<blockquote class="gmail_quote" style="margin: 5px 5px; padding-left: 10px; border-left: thin solid #d35400;">
<div class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class="">Hi,
<div class=""><br class=""></div>
<div class="">I’m fairly new to this community so I hope I’m not asking a very trivial question.</div>
<div class="">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 class="">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 class=""><br class=""></div>
<div class="">Thanks a lot for any kind of help.</div>
</div>
<div name="messageSignatureSection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif" class=""><br class="">
Cheers,
<div class="">Laurin</div>
</div>
</div>
_______________________________________________<br class="">
clangd-dev mailing list<br class="">
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank" class="">clangd-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br class=""></blockquote>
</div>
</blockquote>
</div>
</div>
_______________________________________________<br class="">
clangd-dev mailing list<br class="">
<a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br class=""></div>
</blockquote>
</div>
<br class=""></div>
</blockquote>
</div>
</div></blockquote></body></html>