[llvm-bugs] [Bug 39360] New: clang-cl should support /FAs to emit source code

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 19 16:50:54 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39360

            Bug ID: 39360
           Summary: clang-cl should support /FAs to emit source code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sfinae at hotmail.com
                CC: llvm-bugs at lists.llvm.org

clang-cl supports only /FA to emit assembler, not /FAs which emits assembler
and source code. This significantly increases the difficulty of understanding
Clang codegen.

In the example below, MSVC /FAs prints "return x / 100;".

C:\Temp>type meow.cpp
unsigned long long div100(unsigned long long x) {
    return x / 100;
}

C:\Temp>cl /EHsc /nologo /W4 /O2 /c /FAs meow.cpp && type meow.asm
meow.cpp
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.20.26504.99

include listing.inc

INCLUDELIB LIBCMT
INCLUDELIB OLDNAMES

PUBLIC  ?div100@@YA_K_K at Z                               ; div100
; Function compile flags: /Ogtpy
; File C:\Temp\meow.cpp
;       COMDAT ?div100@@YA_K_K at Z
_TEXT   SEGMENT
x$ = 8
?div100@@YA_K_K at Z PROC                                  ; div100, COMDAT

; 2    :     return x / 100;

        mov     rax, 5165088340638674453                ; 47ae147ae147ae15H
        mul     rcx
        sub     rcx, rdx
        shr     rcx, 1
        lea     rax, QWORD PTR [rdx+rcx]
        shr     rax, 6

; 3    : }

        ret     0
?div100@@YA_K_K at Z ENDP                                  ; div100
_TEXT   ENDS
END

C:\Temp>clang-cl -m64 /EHsc /nologo /W4 /O2 /c /FAs meow.cpp
clang-cl.exe: warning: argument unused during compilation: '/FAs'
[-Wunused-command-line-argument]

C:\Temp>clang-cl -m64 /EHsc /nologo /W4 /O2 /c /FA meow.cpp && type meow.asm
        .text
        .intel_syntax noprefix
        .def     "?div100@@YA_K_K at Z";
        .scl    2;
        .type   32;
        .endef
        .section        .text,"xr",one_only,"?div100@@YA_K_K at Z"
        .globl  "?div100@@YA_K_K at Z"     # -- Begin function ?div100@@YA_K_K at Z
        .p2align        4, 0x90
"?div100@@YA_K_K at Z":                    # @"?div100@@YA_K_K at Z"
# %bb.0:
        shr     rcx, 2
        movabs  rdx, 2951479051793528259
        mov     rax, rcx
        mul     rdx
        shr     rdx, 2
        mov     rax, rdx
        ret
                                        # -- End function
        .section        .drectve,"yn"
        .ascii  " /DEFAULTLIB:libcmt.lib"
        .ascii  " /DEFAULTLIB:oldnames.lib"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181019/cca39cb3/attachment.html>


More information about the llvm-bugs mailing list