Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

assembler output customization #17464

Open Quuxplusone opened 10 years ago

Quuxplusone commented 10 years ago
Bugzilla Link PR17465
Status NEW
Importance P normal
Reported by Trass3r (trass3r@gmail.com)
Reported on 2013-10-03 07:29:42 -0700
Last modified on 2019-09-04 13:07:57 -0700
Version trunk
Hardware PC All
CC gonzalo.gadeschi@gmail.com, jryans@gmail.com, kkhoo@perfwizard.com, llvm-bugs@lists.llvm.org, nicolasweber@gmx.de
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
It would be nice to have if clang supported gcc's -masm=dialect switch so I can
get readable asm without a special case for clang to use -mllvm --x86-asm-
syntax=intel.

But more importantly I'd love to have a way to generate assembler output with
properly embedded source code, especially on Linux.
But that would even allow to support the /FAs switch in clang-cl and enable me
to seamlessly use my existing VS addin for quick asm inspection with the newly
available clang toolkit.

I already tried several different approaches.
* -fverbose-asm is pretty useless.
* Then there's the -Wa trick (http://www.fclose.com/240/generate-a-mixed-source-
and-assembly-listing-using-gcc) which only works with gcc.
* objdump works with both:
  clang++ -c -g -O3 test.cpp
  objdump -dSC -M intel test.o

But neither of these approaches reaches the readability of /FAs (in combination
with AsmHighlighter):

?set@Point@@QEAAXNNN@Z PROC    ; Point::set, COMDAT
; 47   :     void set(const double X, const double Y, const double Z) { _xyz[0]
= X; _xyz[1] = Y; _xyz[2] = Z; }

    movsdx    QWORD PTR [rcx], xmm1
    movsdx    QWORD PTR [rcx+8], xmm2
    movsdx    QWORD PTR [rcx+16], xmm3
    ret       0
?set@Point@@QEAAXNNN@Z ENDP    ; Point::set

In this case source code is properly injected as assembler comments and there
are no line numbers or machine code confusing the syntax highlighter.
But the /FA switch also allows you to add these if you need.
Quuxplusone commented 10 years ago

Here's a patch for -masm: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140505/105299.html

For the other thing, -fno-integrated-as -Xassembler -adhln might do the trick.

Quuxplusone commented 8 years ago

+1 I would also like to generate source code annotated with assembly in a particular dialect. This is kind of a must to verify the assembly generated for a particular snippet of code within a large project.

Quuxplusone commented 7 years ago

fwiw, -masm=intel has been working since 208683 (clang 3.5).

Quuxplusone commented 5 years ago

MCAsmStreamer::EmitDwarfLocDirective is a POI for this.

Quuxplusone commented 4 years ago

Cross-ref "[cfe-dev] RFC: Add a way to interleave source code in assembler output" and https://reviews.llvm.org/D30897 / https://reviews.llvm.org/D30898 linked from there (apparently stalled, but maybe a good start).

See also bug 39360.