<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal>I’m noticing the X86InstrInfo::GetInstSizeInBytes() function
returning incorrect sizes for some instructions.  I looked through the llvm-dev
archives and noticed that a patch was submitted once in April 2009 for
instruction length calculation on amd-64.  I’m using Intel Core 2 Duo
(64 bit) so maybe there is a similar issue?  I don’t have another computer
I can test this on to see if that’s it though.  If this turns out to
be a bug, rather than some misuse/misinterpretation of the function on my part
I can resubmit it via that channel.  <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>The instructions I’ve noticed this occurring for are: <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>MOV32mi, LEA32r, MOV32mr, and MOV32rm <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>The length of LEA32r is calculated correctly some of the
time.  Same for MOV32mr and MOV32rm.  The length of MOV32mi seems to
always be wrong.<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>An example breakdown of emitted Machine Instructions –
 the machine instructions are those outputted when I pass the -debug
option to lli.exe (formatted by me for readability, left to right):<o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>8d 9c 24 30 0a 00 00                         LEA32r                  calculated
length: 7         ok<o:p></o:p></p>

<p class=MsoNormal>8d 6c 24 28                                          LEA32r                  calculated
length: 7         incorrect<o:p></o:p></p>

<p class=MsoNormal>8b 86 24 0a 39 00                               MOV32rm           calculated
length: 6         ok<o:p></o:p></p>

<p class=MsoNormal>8b 44 24 10                                          MOV32rm           calculated
length: 7         incorrect<o:p></o:p></p>

<p class=MsoNormal>89 84 24 34 14 00 00                         MOV32mr           calculated
length: 7         ok<o:p></o:p></p>

<p class=MsoNormal>89 2c 24                                                MOV32mr           calculated
length: 7         incorrect<o:p></o:p></p>

<p class=MsoNormal>c7 44 24 08 08 0a 00 00                    MOV32mi            calculated
length: 11       incorrect<o:p></o:p></p>

<p class=MsoNormal>c7 04 24 20 00 38 00                          MOV32mi            calculated
length: 11       incorrect  <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>If more information is needed let me know and I’ll send
it.  <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>Thank you in advance and best regards, <o:p></o:p></p>

<p class=MsoNormal><o:p> </o:p></p>

<p class=MsoNormal>John Butterworth<o:p></o:p></p>

</div>

</body>

</html>