Clang-Cl - support for the FAcs flag?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang-Cl - support for the FAcs flag?

Yaron Keren via cfe-dev
Hello Clang-Dev-List-People,

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?

For those how doesn't know the flag:
It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.

Kind regards
Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang-Cl - support for the FAcs flag?

Yaron Keren via cfe-dev
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.


On Tue, Mar 6, 2018 at 12:59 AM via cfe-dev <[hidden email]> wrote:
Hello Clang-Dev-List-People,

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?

For those how doesn't know the flag:
It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.

Kind regards
Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang-Cl - support for the FAcs flag?

Yaron Keren via cfe-dev
But patches are of course gladly accepted, if you want to give it a try yourself :-)

Other ways to get what you want:
* If you use vim, whodis (https://github.com/sgraham/whodis) 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.
* Ideally we'd add clang-cl support to godbolt.org. I looked at this for a tiny bit a few months ago (https://github.com/mattgodbolt/compiler-explorer/issues/204) 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)

On Tue, Mar 6, 2018 at 12:54 PM, Reid Kleckner via cfe-dev <[hidden email]> wrote:
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.


On Tue, Mar 6, 2018 at 12:59 AM via cfe-dev <[hidden email]> wrote:
Hello Clang-Dev-List-People,

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?

For those how doesn't know the flag:
It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.

Kind regards
Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang-Cl - support for the FAcs flag?

Yaron Keren via cfe-dev
I don't think I'm good enough to make a patch for clang.
Is there at least a way to have the line numbers of the source code in the assembly output?



From:        Nico Weber <[hidden email]>
To:        Reid Kleckner <[hidden email]>
Cc:        [hidden email], cfe-dev <[hidden email]>
Date:        06.03.2018 19:33
Subject:        Re: [cfe-dev] Clang-Cl - support for the FAcs flag?
Sent by:        [hidden email]




But patches are of course gladly accepted, if you want to give it a try yourself :-)

Other ways to get what you want:
* If you use vim, whodis (https://github.com/sgraham/whodis) 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.
* Ideally we'd add clang-cl support to godbolt.org. I looked at this for a tiny bit a few months ago (https://github.com/mattgodbolt/compiler-explorer/issues/204) 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)

On Tue, Mar 6, 2018 at 12:54 PM, Reid Kleckner via cfe-dev <[hidden email]> wrote:
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.


On Tue, Mar 6, 2018 at 12:59 AM via cfe-dev <[hidden email]> wrote:
Hello Clang-Dev-List-People,

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?


For those how doesn't know the flag:

It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.


Kind regards

Björn


Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang-Cl - support for the FAcs flag?

Yaron Keren via cfe-dev
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.https://github.com/nico/demumble) to unmangle function names.

$ cat test.cc
int f(int a, int b) {
  int c = a + b;
  int d = a * b;
  return c / d;
}

$ bin/clang-cl /Z7 /c /FA test.cc && cat test.asm | demumble 
...
"int __cdecl f(int,int)":                          # @"\01int __cdecl f(int,int)"
...
.cv_loc 0 1 1 0 is_stmt 0       # test.cc:1:0
.cv_fpo_proc "int __cdecl f(int,int)" 8
# %bb.0:                                # %entry
push ebp
.cv_fpo_pushreg ebp
mov ebp, esp
.cv_fpo_setframe ebp
sub esp, 16
.cv_fpo_stackalloc 16
.cv_fpo_endprologue
mov eax, dword ptr [ebp + 12]
mov ecx, dword ptr [ebp + 8]
Ltmp0:
.cv_loc 0 1 2 0                 # test.cc:2:0
mov edx, dword ptr [ebp + 8]
add edx, dword ptr [ebp + 12]
mov dword ptr [ebp - 4], edx
.cv_loc 0 1 3 0                 # test.cc:3:0
mov edx, dword ptr [ebp + 8]
imul edx, dword ptr [ebp + 12]
mov dword ptr [ebp - 8], edx
.cv_loc 0 1 4 0                 # test.cc:4:0
mov edx, dword ptr [ebp - 4]
mov dword ptr [ebp - 12], eax # 4-byte Spill
mov eax, edx
cdq
idiv dword ptr [ebp - 8]
mov dword ptr [ebp - 16], ecx # 4-byte Spill
add esp, 16
pop ebp
ret

See the `# test.cc:N` comments at the end of the .cv_loc lines.


On Wed, Mar 7, 2018 at 8:05 AM, <[hidden email]> wrote:
I don't think I'm good enough to make a patch for clang.
Is there at least a way to have the line numbers of the source code in the assembly output?



From:        Nico Weber <[hidden email]>
To:        Reid Kleckner <[hidden email]>
Cc:        [hidden email], cfe-dev <[hidden email]>
Date:        06.03.2018 19:33
Subject:        Re: [cfe-dev] Clang-Cl - support for the FAcs flag?
Sent by:        [hidden email]




But patches are of course gladly accepted, if you want to give it a try yourself :-)

Other ways to get what you want:
* If you use vim, whodis (https://github.com/sgraham/whodis) 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.
* Ideally we'd add clang-cl support to godbolt.org. I looked at this for a tiny bit a few months ago (https://github.com/mattgodbolt/compiler-explorer/issues/204) 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)

On Tue, Mar 6, 2018 at 12:54 PM, Reid Kleckner via cfe-dev <[hidden email]> wrote:
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.


On Tue, Mar 6, 2018 at 12:59 AM via cfe-dev <[hidden email]> wrote:
Hello Clang-Dev-List-People,

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?


For those how doesn't know the flag:

It generates assembly output, but also mixes the C/C++ source code as comments into it. This really helps to find points of interest.


Kind regards

Björn


Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.

_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev