<div dir="ltr">Yes: If you also pass /Z7 to clang-cl, then the assembly will contain debug information, containing line markers. You can also pass the assembly through a demangler (MSVC's undname, or e.g.<a href="https://github.com/nico/demumble">https://github.com/nico/demumble</a>) to unmangle function names.<div><br></div><div><div>$ cat test.cc</div><div>int f(int a, int b) {</div><div> int c = a + b;</div><div> int d = a * b;</div><div> return c / d;</div><div>}</div></div><div><br></div><div><div>$ bin/clang-cl /Z7 /c /FA test.cc && cat test.asm | demumble </div><div>...</div><div>"int __cdecl f(int,int)": # @"\01int __cdecl f(int,int)"<br></div><div>...</div><div><span style="white-space:pre"> </span>.cv_loc<span style="white-space:pre"> </span>0 1 1 0 is_stmt 0 # test.cc:1:0</div><div><span style="white-space:pre"> </span>.cv_fpo_proc<span style="white-space:pre"> </span>"int __cdecl f(int,int)" 8</div><div># %bb.0: # %entry</div><div><span style="white-space:pre"> </span>push<span style="white-space:pre"> </span>ebp</div><div><span style="white-space:pre"> </span>.cv_fpo_pushreg<span style="white-space:pre"> </span>ebp</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>ebp, esp</div><div><span style="white-space:pre"> </span>.cv_fpo_setframe<span style="white-space:pre"> </span>ebp</div><div><span style="white-space:pre"> </span>sub<span style="white-space:pre"> </span>esp, 16</div><div><span style="white-space:pre"> </span>.cv_fpo_stackalloc<span style="white-space:pre"> </span>16</div><div><span style="white-space:pre"> </span>.cv_fpo_endprologue</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>eax, dword ptr [ebp + 12]</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>ecx, dword ptr [ebp + 8]</div><div>Ltmp0:</div><div><span style="white-space:pre"> </span>.cv_loc<span style="white-space:pre"> </span>0 1 2 0 # test.cc:2:0</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>edx, dword ptr [ebp + 8]</div><div><span style="white-space:pre"> </span>add<span style="white-space:pre"> </span>edx, dword ptr [ebp + 12]</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>dword ptr [ebp - 4], edx</div><div><span style="white-space:pre"> </span>.cv_loc<span style="white-space:pre"> </span>0 1 3 0 # test.cc:3:0</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>edx, dword ptr [ebp + 8]</div><div><span style="white-space:pre"> </span>imul<span style="white-space:pre"> </span>edx, dword ptr [ebp + 12]</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>dword ptr [ebp - 8], edx</div><div><span style="white-space:pre"> </span>.cv_loc<span style="white-space:pre"> </span>0 1 4 0 # test.cc:4:0</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>edx, dword ptr [ebp - 4]</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>dword ptr [ebp - 12], eax # 4-byte Spill</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>eax, edx</div><div><span style="white-space:pre"> </span>cdq</div><div><span style="white-space:pre"> </span>idiv<span style="white-space:pre"> </span>dword ptr [ebp - 8]</div><div><span style="white-space:pre"> </span>mov<span style="white-space:pre"> </span>dword ptr [ebp - 16], ecx # 4-byte Spill</div><div><span style="white-space:pre"> </span>add<span style="white-space:pre"> </span>esp, 16</div><div><span style="white-space:pre"> </span>pop<span style="white-space:pre"> </span>ebp</div><div><span style="white-space:pre"> </span>ret</div></div><div><br></div><div>See the `# test.cc:N` comments at the end of the .cv_loc lines.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 7, 2018 at 8:05 AM, <span dir="ltr"><<a href="mailto:bjoern.gaier@horiba.com" target="_blank">bjoern.gaier@horiba.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><font size="2" face="sans-serif">I don't think I'm good enough to make a
patch for clang.</font>
<br><font size="2" face="sans-serif">Is there at least a way to have the
line numbers of the source code in the assembly output?</font>
<br>
<br>
<br>
<br><font size="1" color="#5f5f5f" face="sans-serif">From:
</font><font size="1" face="sans-serif">Nico Weber <<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></font>
<br><font size="1" color="#5f5f5f" face="sans-serif">To:
</font><font size="1" face="sans-serif">Reid Kleckner <<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></font>
<br><font size="1" color="#5f5f5f" face="sans-serif">Cc:
</font><font size="1" face="sans-serif"><a href="mailto:bjoern.gaier@horiba.com" target="_blank">bjoern.gaier@horiba.com</a>,
cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></font>
<br><font size="1" color="#5f5f5f" face="sans-serif">Date:
</font><font size="1" face="sans-serif">06.03.2018 19:33</font>
<br><font size="1" color="#5f5f5f" face="sans-serif">Subject:
</font><font size="1" face="sans-serif">Re: [cfe-dev]
Clang-Cl - support for the FAcs flag?</font>
<br><font size="1" color="#5f5f5f" face="sans-serif">Sent by:
</font><font size="1" face="sans-serif"><a href="mailto:thakis@google.com" target="_blank">thakis@google.com</a></font>
<br>
<hr noshade><div class="HOEnZb"><div class="h5">
<br>
<br>
<br><font size="3">But patches are of course gladly accepted, if you want
to give it a try yourself :-)</font>
<br>
<br><font size="3">Other ways to get what you want:</font>
<br><font size="3">* If you use vim, whodis (</font><a href="https://github.com/sgraham/whodis" target="_blank"><font size="3" color="blue"><u>https://github.com/sgraham/<wbr>whodis</u></font></a><font size="3">)
can show the assembly of the current function and it color-codes which
parts of the function become which assembly. It works reasonably well.
I haven't tried it on Windows yet, but in a chrome/win cross build on linux
it worked well.</font>
<br><font size="3">* Ideally we'd add clang-cl support to </font><a href="http://godbolt.org/" target="_blank"><font size="3" color="blue"><u>godbolt.org</u></font></a><font size="3">.
I looked at this for a tiny bit a few months ago (</font><a href="https://github.com/mattgodbolt/compiler-explorer/issues/204" target="_blank"><font size="3" color="blue"><u>https://github.com/<wbr>mattgodbolt/compiler-explorer/<wbr>issues/204</u></font></a><font size="3">)
but got distracted (and I'm not super likely to get re-tracted…uh…back-on-track
soon – so this would be a cool project for someone too)</font>
<br>
<br><font size="3">On Tue, Mar 6, 2018 at 12:54 PM, Reid Kleckner via cfe-dev
<</font><a href="mailto:cfe-dev@lists.llvm.org" target="_blank"><font size="3" color="blue"><u>cfe-dev@lists.llvm.org</u></font></a><font size="3">>
wrote:</font>
<br><font size="3">I don't think there are any plans to add it. We don't
have support for the equivalent GCC flags yet either (-Wa,-adhln, I think?),
so this isn't just a matter of hooking things up. The feature would need
to be implemented from scratch.</font>
<br><font size="3"><br>
</font>
<br><font size="3">On Tue, Mar 6, 2018 at 12:59 AM via cfe-dev <</font><a href="mailto:cfe-dev@lists.llvm.org" target="_blank"><font size="3" color="blue"><u>cfe-dev@lists.llvm.org</u></font></a><font size="3">>
wrote:</font>
<br><font size="2" face="sans-serif">Hello Clang-Dev-List-People,</font><font size="3">
<br>
</font><font size="2" face="sans-serif"><br>
I use clang-cl integrated to Visual Studio to compile my projects. This
is working fine. I wanted to ask, if there are plans for supporting the
/FAcs flag of the visual studio compiler? Or at least is there a work around?</font><font size="3">
<br>
</font><font size="2" face="sans-serif"><br>
For those how doesn't know the flag:</font><font size="3"> </font><font size="2" face="sans-serif"><br>
It generates assembly output, but also mixes the C/C++ source code as comments
into it. This really helps to find points of interest.</font><font size="3">
<br>
</font><font size="2" face="sans-serif"><br>
Kind regards</font><font size="3"> </font><font size="2" face="sans-serif"><br>
Björn</font><font size="3"> </font><font size="2" face="sans-serif"><br>
<br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.<br>
</font>
<br><font size="3">______________________________<wbr>_________________<br>
cfe-dev mailing list</font><font size="3" color="blue"><u><br>
</u></font><a href="mailto:cfe-dev@lists.llvm.org" target="_blank"><font size="3" color="blue"><u>cfe-dev@lists.llvm.org</u></font></a><font size="3" color="blue"><u><br>
</u></font><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank"><font size="3" color="blue"><u>http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</u></font></a>
<br><font size="3"><br>
______________________________<wbr>_________________<br>
cfe-dev mailing list</font><font size="3" color="blue"><u><br>
</u></font><a href="mailto:cfe-dev@lists.llvm.org" target="_blank"><font size="3" color="blue"><u>cfe-dev@lists.llvm.org</u></font></a><font size="3" color="blue"><u><br>
</u></font><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" target="_blank"><font size="3" color="blue"><u>http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</u></font></a><font size="3"><br>
</font>
<br>
<br>
<br><font size="2" face="sans-serif"><br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.<br>
<br>
</font>
</div></div></blockquote></div><br></div>