<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 --- - opt -O1 creates a file which output differs when run with lli -force-interpreter."
   href="http://llvm.org/bugs/show_bug.cgi?id=21170">21170</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>opt -O1 creates a file which output differs when run with lli -force-interpreter.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>karl.tarbe@cyber.ee
          </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>Created <span class=""><a href="attachment.cgi?id=13147" name="attach_13147" title="Original program, that prints out some data.">attachment 13147</a> <a href="attachment.cgi?id=13147&action=edit" title="Original program, that prints out some data.">[details]</a></span>
Original program, that prints out some data.

I have a simple program in llvm IR, that prints out data in hex 24 values on a
row.

When I run it with
strace lli -force-interpreter=true print.ll > /tmp/file

The last lines of strace are:
lseek(1, 0, SEEK_CUR)                   = 0
fstat(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
write(1, "fa ff ff 7f bf fe ff ff 4f 00 00"..., 606) = 606
close(1)                                = 0
brk(0x1def000)                          = 0x1def000
exit_group(0)                           = ?
+++ exited with 0 +++

Now if I do: opt -O1 print.ll -o print.bc
and run that
strace lli -force-interpreter=true print.bc > /tmp/file

The last lines of strace are:
lseek(1, 0, SEEK_CUR)                   = 0
fstat(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fstat(1, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x7feb8e3e5000
write(1, "fa ff ff 7f bf fe ff ff 4f 00 00"..., 597) = 597
close(1)                                = 0
brk(0x221b000)                          = 0x221b000
write(1, "\n\n\n\n\n\n\n\n\n", 9)       = -1 EBADF (Bad file descriptor)
exit_group(0)                           = ?
+++ exited with 0 +++

print.ll produces a correct file.
print.bc (*optimized variant) produces an incorrect file (no newline
characters).

And the problem does not appear when not forcing to use interpreter, or when
not redirecting the output to a file.</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>