<div><div dir="auto">llvm-dva (not yet in tree but see <div dir="auto"><a href="https://reviews.llvm.org/D88661" target="_blank">https://reviews.llvm.org/D88661</a> ) might also be useful here depending on how mature the codeview support is (cc Carlos - please correct me if anything I said is wrong!). </div><div dir="auto"><br></div><div dir="auto">I think, in theory it should allow us to do a direct comparison between the debug info generated by clang-cl, and that generated by cl.exe for the same code (and also with clang's DWARF output if that's possible to generate too) so we can see exactly what the differences are and what's missing.</div><div dir="auto"><br></div><div dir="auto">When I previously looked into some of this stuff using dexter I found a few examples like <div dir="auto"><a href="https://bugs.llvm.org/show_bug.cgi?id=37682">https://bugs.llvm.org/show_bug.cgi?id=37682</a> where clang was comparing unfavorably with MSVC because it was doing more aggressive loop optimizations. I don't know how widespread it is or whether it's still the case in more recent versions, but I certainly ran into it on more than one occasion where MSVC was doing things like leaving stores in loops whereas clang would hoist it instead for better codegen but an unfortunately worse debugging experience. </div><div dir="auto"><br></div><div dir="auto">-Greg</div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div></div></div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 10 Mar 2021 at 20:02, Alexandre Ganea via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">





<div lang="EN-CA" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span lang="FR-CA"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="FR-CA"><u></u> <u></u></span></p>
<div>
<div style="border-style:solid none none;border-top-width:1pt;padding:3pt 0cm 0cm;border-top-color:rgb(225,225,225)">
<p class="MsoNormal"><b><span lang="FR">De :</span></b><span lang="FR"> Alexandre Ganea
<br>
<b>Envoyé :</b> March 10, 2021 3:02 PM<br>
<b>À :</b> 'Tobias Hieta' <<a href="mailto:tobias@plexapp.com" target="_blank">tobias@plexapp.com</a>>; Adrian McCarthy <<a href="mailto:amccarth@google.com" target="_blank">amccarth@google.com</a>>; 'James Henderson' <<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>><br>
<b>Objet :</b> RE: [llvm-dev] Debug information with clang-cl on Windows<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span>DExTer can probably help bisecting to the specific optimization pass(es) that cause the debug infos to be omitted?
<a href="https://lists.llvm.org/pipermail/llvm-dev/2018-August/125780.html" target="_blank">https://lists.llvm.org/pipermail/llvm-dev/2018-August/125780.html</a><u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><span>+James.<u></u><u></u></span></p>
<p class="MsoNormal"><span><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="FR">De :</span></b><span lang="FR"> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
<b>De la part de</b> Tobias Hieta via llvm-dev<br>
<b>Envoyé :</b> March 10, 2021 2:26 PM<br>
<b>À :</b> Adrian McCarthy <<a href="mailto:amccarth@google.com" target="_blank">amccarth@google.com</a>><br>
<b>Cc :</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Objet :</b> Re: [llvm-dev] Debug information with clang-cl on Windows<u></u><u></u></span></p></div></div><div lang="EN-CA" link="blue" vlink="purple"><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hello,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks for your reply!<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Is it possible to disable optimisations with clang-cl and see if that makes a difference?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I will also try to build with clang 12 instead and see if there is any improvement. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Happy to try to reproduce or fix the issue - but I am unfamiliar with this debug info on windows and how to even start looking into it, any pointers are appreciated. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Tobias. <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, 10 Mar 2021 at 00:45, Adrian McCarthy <<a href="mailto:amccarth@google.com" target="_blank">amccarth@google.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt;border-left-color:rgb(204,204,204)">
<div>
<p class="MsoNormal">I believe that, even with `/Od` (that's Microsoft for "disable optimizations"), clang-cl applies some optimizations.<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">People on my team have been fixing debug info quality bugs for Windows for a while.  I don't have specific knowledge of these issues, but it's possible newer versions (like 12 or head) may have solved this.  We're somewhat more focused
 on 64-bit than 32-bit builds, so you might encounter some differences there.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">If you can reproduce the problem with a reduced code sample, please file a bug with all the deets.  If you do some debugging yourself, please let us know what you find.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Mar 9, 2021 at 2:46 PM David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt;border-left-color:rgb(204,204,204)">
<div>
<p class="MsoNormal">I would guess there's no one bug here - debug info quality (specifically/especially the location of variables when compiling with optimizations enabled) is a long tail/sliding scale of issues. LLVM is, on the whole, not spectacular at this
 - a matter of bugs to fix, some small/simple, others more systemic/representational.<br>
<br>
If you're interested in contributing to this work - generally the first step is to isolate the problem - first thing you can do is if you have some experience dumping/examining debug info in object files, you can dump/examine the relevant object files then
 try to reduce/remove code from the relevant objects, etc, to see what the minimal example is that'll make it easier to figure out how to fix.<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Mar 9, 2021 at 12:37 AM Tobias Hieta via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt;border-left-color:rgb(204,204,204)">
<p class="MsoNormal">Hello,<br>
<br>
We recently switched our windows builds from the CL compiler to<br>
clang-cl. This was a pretty big jump in terms of code generation and<br>
having a uniform compiler across all the major platforms.<br>
<br>
Our setup is that our Windows developer use MSVC as the IDE and<br>
compile with our own build of clang-cl and link with lld-link.<br>
<br>
Some of the developers noticed that some of the debug information are<br>
not as good as with CL. Or rather some variables seems to be optimized<br>
out, this is what the IDE says, see attached screenshot. I have tried<br>
to figure out if there is a rhyme and reason to what variables are<br>
gone - but I have not been able to see any pattern.<br>
<br>
Our command line is:<br>
<br>
clang-cl.exe /nologo -DUNICODE -DUSE_BREAKPAD -DWIN32<br>
-DWIN32_LEAN_AND_MEAN -DWINVER=0x0601 -D_CRT_NONSTDC_NO_DEPRECATE<br>
-D_CRT_SECURE_NO_WARNINGS -D_LEGACY_NAT_TRAVERSAL_ -D_REENTRANT<br>
-D_SCL_SECURE_NO_WARNINGS -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS<br>
-D_UNICODE -D_WIN32_WINNT=0x0601 -D_WINSOCK_DEPRECATED_NO_WARNINGS<br>
-Iincludes -m32 -fdiagnostics-absolute-paths<br>
--target=i686-windows-msvc -m32 /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0<br>
/Od /RTC1 -MDd /Zm512 /EHsc /bigobj /W3 -Werror -Wsign-compare<br>
-Wno-reorder-ctor -Wno-delete-non-virtual-dtor -Wunused-variable<br>
-Wuninitialized -std:c++14<br>
<br>
Is there any good way to debug this or is it a known limitation with<br>
clang-cl or 32 bit (we don't do 64 yet - but with clang-cl we hope to<br>
move towards that soon). Or am I missing some flags?<br>
<br>
Thanks,<br>
Tobias<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><u></u><u></u></p>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</div>