<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [X86] [ASM INTEL SYNTAX] clang generates incorrect assembler code when x86-asm-syntax=intel"
   href="https://bugs.llvm.org/show_bug.cgi?id=34617">34617</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[X86] [ASM INTEL SYNTAX] clang generates incorrect assembler code when x86-asm-syntax=intel
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>konstantin.belochapka@sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider the following source code:
-----------------------------------------------------------------
char X[ 4 ];
extern char testCall084(long    n, char* y);
volatile char* px;
char test084(long x0) {
    char rc = testCall084(x0, X);
    px =  X;
    return rc;
}

Running:

$clang -S -O1 -mllvm --x86-asm-syntax=intel source.cpp

Produces the following assembler source:
--------------------------------------------------------------
_Z7test084l:
        push    rax
        mov     esi, X
        call    _Z11testCall084lPc
        mov     qword ptr [rip + px], X
        pop     rcx
        ret

GNU assembler interprets: 
1       mov     esi, X
2       mov     qword ptr [rip + px], X
as:
1       mov     esi, [X]
2       mov     qword ptr [rip + px], [X]

which produces incorrect binary code for first instruction
and error message:
"too many memory references for `mov'" for second instruction.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>