<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Invalid lgdt/lidt instruction generation on 32Bit x86 using intel syntax" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24089&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=jNCePVehnqwGGv38Ygdp7jGJZQsoAYzEoatIn8RCAu0&s=R7n7rcEIpbC2JFRVk4o8Ui3pFP1gCUf_mLrBe1oobUo&e=">24089</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid lgdt/lidt instruction generation on 32Bit x86 using intel syntax
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>Mrrrgbl@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When you try to load GDTR/IDTR registers using intel syntax, like that:

static struct __attribute__((packed)) GDTValue{
    uint16_t limit;
    addr_t addr;
}GDTValue;

__asm lgdt [GDTValue];

It produces this llvm asm:
%0 = tail call i32 asm sideeffect inteldialect "lgdt dword ptr $1",
"={eax},*m,~{dirflag},~{fpsr},~{flags}"(%struct.GDTValue*
@MemoryManagerInit.GDTValue) #4, !srcloc !42

and 

66 0f 01 15 x86 opcode. 

However, if you using 32 bit environment (I compiled with -m32 option to be
sure), prefix 66 makes this instruction to be 16 bit version. This loads only 5
bytes in register instead of 6, making its value totaly incorrect. Using 'dword
ptr' or 'word ptr' specifiers doesn't make any change (I assumed there was bug
with swapped prefix for 16/32 bit). Using asm(...) with ATT syntax instead of
__asm produces right code, which I use as workaround.</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>