<html>
    <head>
      <base href="http://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 --- - Miscompile with x86 hosted release compiler targeting x64"
   href="http://llvm.org/bugs/show_bug.cgi?id=19644">19644</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with x86 hosted release compiler targeting x64
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>MC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>douglas_yung@playstation.sony.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>I am running an x86 linux hosted release compiler targeting x64 linux, and I am
seeing the dumper which writes the generated machine instructions to a file
seems to be messing up somewhere in the process. Note that this only seems to
occur in the x86 release compiler when targeting x64. A debug+asserts build of
the same compiler does NOT exhibit this issue. 

Test environment:
•    Compiler: i386-pc-linux-gnu
•    Compiler build: Release (does not repro with Debug+Asserts built compiler)
•    Target: x86_64-pc-linux-gnu
•    Host OS: Linux (Ubuntu 13.10)
•    SVN Revision: 207280
•    Compiler used to build LLVM: gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1

The LLVM IR which reproduces the issue is the following:

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

%struct.S5303X7 = type { i56, [2 x i32] }

; Function Attrs: uwtable
define internal void @_ZL12Test_S5303X7v() #0 {
  %lv = alloca %struct.S5303X7*, align 8
  %1 = call noalias i8* @_Znwm(i64 16) #3
  %2 = bitcast i8* %1 to %struct.S5303X7*
  store %struct.S5303X7* %2, %struct.S5303X7** %lv, align 8
  %3 = load %struct.S5303X7** %lv, align 8
  %4 = bitcast %struct.S5303X7* %3 to i64*
  %5 = load i64* %4, align 4
  %6 = and i64 %5, -2251799813685249
  store i64 %6, i64* %4, align 4
  ret void
}

; Function Attrs: nobuiltin
declare noalias i8* @_Znwm(i64) #2

To see the issue, compile this using a x86 hosted Release build of the compiler
and use the command “llc repro.ll –filetype=asm –o repro.s –O0”. If you look at
the generated assembly file, you will see that the constant “-2251799813685249”
has been changed to “-1”. If you compile with a Debug+Asserts compiler, the
constant is unaltered. If you add the options “-print-machineinstrs” and
“-show-mc-inst” you can see that after each pass the constant is still correct,
but once it gets written to the file, it is incorrectly changed to -1.</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>