<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 --- - Bad optimized LLVM IR generation after PowerPC optimization using llopt -O2"
   href="https://llvm.org/bugs/show_bug.cgi?id=24394">24394</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bad optimized LLVM IR generation after PowerPC optimization using  llopt -O2
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>matt.davis@pgroup.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14709" name="attach_14709" title="Source, non-llopt, and llopt llvm IR">attachment 14709</a> <a href="attachment.cgi?id=14709&action=edit" title="Source, non-llopt, and llopt llvm IR">[details]</a></span>
Source, non-llopt, and llopt llvm IR

I have a simple TLS test case in C.  This test runs to completion when
assembled in llvm 3.6 with llopt at -O2, or in 3.7 NOT using opt -O2.  However,
when assembled when building the code using llc 3.7 with llopt -O2 a reference
to a local variable creates a segmentation fault.

I have the offending code in LLVM IR attached (code generated before and after
opt -O2).  I also have the original C source that was used to generate the llvm
ir.  I have stripped the llvm ir samples, making them more readable.

What you will see is that opt removed the assignment of the integer value, 10,
to the TLS variable "x"

Additionally, the TLS variable "x" has been converted from i32 to i1:
Before llopt:
@x = internal thread_local  global i32 100, align 4

After llopt:
@x = internal thread_local unnamed_addr global i1 false

Works:
llvm/3.7/bin/llc ./test.ll -mcpu=native -O2 -post-RA-scheduler=0
-relocation-model=pic -o ./test.s

/usr/bin/as ./test.s -mpower8 -many -o test.o


Fails:
llvm/3.7/bin/opt -O2 ./test.ll -S -o ./test_opt.ll

llvm/3.7/bin/llc ./test_opt.ll -mcpu=native -O2 -post-RA-scheduler=0
-relocation-model=pic -o ./test_opt.s

/usr/bin/as ./test_opt.s -mpower8 -many -o test_opt.o</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>